Closed
Description
Issue Description
After reading #6360 I attempted to pass a custom graphql schema into Parse options, just like the example suggests. (see code below)
However, /graphql ceases to respond and outputs an error to the console.
I am pretty sure I have just missed some little detail, but after extensive research I can't find it. There's not much documentation around supplying a custom schema (except for the PR or supplying a .graphql file and using a Cloud Code-based resolver, which doesn't suffice for my use case, though), so I'd appreciate a slight nudge in the right direction.. :)
Steps to reproduce
- Start custom parse-server using JS (I copied the approach from parse-server cli binary)
- Pass custom graphql schema to options.graphQLSchema
options.graphQLSchema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: {
// Here we define a custom Query field with the associated resolver
customQuery: {
type: new GraphQLNonNull(GraphQLString),
args: {
message: { type: new GraphQLNonNull(GraphQLString) },
},
resolve: (source, args, context, queryInfo) => {
console.log('source', source);
console.log('args', args);
console.log('context', context);
console.log('queryInfo', queryInfo);
return args.message;
},
},
},
}),
});
- Request /graphql endpoint
Expected Results
The request should resolve and graphql should be usable. My custom query should be usable.
Actual Outcome
/graphql does not respond. Errors in console. (see below)
Environment Setup
-
Server
- parse-server version (Be specific! Don't say 'latest'.) : 4.2.0
- Operating System: Docker, node-lts base image
- Hardware: MacBook Pro 2019
- Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): localhost
-
Database
- MongoDB version: 4.2.8
- Storage engine: default
- Hardware: MacBook Pro 2019
- Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): localhost
Logs/Trace
error: Error: Invalid schema passed
at /parse/node_modules/parse-server/node_modules/graphql-tools/dist/stitching/mergeSchemas.js:125:19
at Array.forEach (<anonymous>)
at mergeSchemasImplementation (/parse/node_modules/parse-server/node_modules/graphql-tools/dist/stitching/mergeSchemas.js:53:13)
at mergeSchemas (/parse/node_modules/parse-server/node_modules/graphql-tools/dist/stitching/mergeSchemas.js:30:12)
at ParseGraphQLSchema.load (/parse/node_modules/parse-server/lib/GraphQL/ParseGraphQLSchema.js:193:61)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async ParseGraphQLServer._getGraphQLOptions (/parse/node_modules/parse-server/lib/GraphQL/ParseGraphQLServer.js:61:17)
at async /parse/node_modules/parse-server/lib/GraphQL/ParseGraphQLServer.js:99:86
Metadata
Metadata
Assignees
Labels
No labels