Closed shani117 closed 6 years ago
I've created example of merging schemas with graphql-tools
here and it works perfectly fine.
Issue might be that both basic-express-server
and nested-mutation-or-query
examples have hello
field at root level and it might cause a conflict.
Could you send me more details about your case, or could you try to "break" example I've created and let me know how you did it so I can reproduce your issue?
This is really weird. I think I'm missing something maybe. So I took your nested-mutation-or-query
example and ran it, works perfectly. Then I just renamed a few things and suddenly I start seeing this error even on the nested-mutation-or-query
example!!
This is the change I did on the base example:
@Schema()
class MyAdvSchema {
@Mutation()
book(bookId: number): BookMutation {
return new BookMutation(bookId);
}
@Query()
hello(): string {
return 'World!';
}
}
export const schema = compileSchema(MyAdvSchema);
Note the change of the Schema class name from MySchema
to MyAdvSchema
.
I even tried to just rename the const export to schemaAdv
and leave the schema class name untouched, same error. Nothing else is changed in the example code. I can't seem to put my finger on what could be causing this behavior. Do you have any thoughts on that?
I'll try your other example you created and see if I can repro something with that example.
Thanks.
Accept my apologies on this one - it was a silly oversight on my part. When supplying the schema to graphqlHTTP, I was not providing the prop name for schema and just passing in the compiled schema directly and that was what was causing the issue. Once I supplied the prop name, and then the compiled/merged schema, everything works correctly.
Once again, sorry for the confusion.
Thanks, Shani.
I was trying to merge 2 different GraphQLSchema created by compiling 2 different typegql schemas using the standard mergeSchemas function from the graphql-tools. After that, when I try to start the server and hit the /graphql endpoint, I get an error saying:
{"errors":[{"message":"GraphQL middleware options must contain a schema."}]}
Is this something that should work as I expect it would? I just took the schema in the "basic-express-server" example and the schema in the "nested-mutation-or-query" example and tried to merge them like so:
Even though the server starts up just fine, trying to navigate to the /graphql endpoint throws the above error.
If this is not the supported way to merge schemas, is there any other way? Any pointers?
Thanks, Shani.