New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stitching schema without a Query shows "Query root type must be provided." #764
Comments
This should be fixed with #527 (see comment here: #746 (comment)). Have you tried bumping to version |
Yes, I am using Here is my reproduction repo: Using
As I described, the schemas to be merged and the merging is located in the file you'll get this response:
Please kindly take a look. Thanks!! |
I am experiencing the same issue. I have numerous schemas that I will stitch together and some of them only have mutations. In my case, makeExecutableSchema throws this error when there is no Query root, which is true because I only have mutations in this particular schema. Currently using 3.0.5 |
same issue here. |
We solves this by just filling in
|
+1 |
We are also seeing this issue and are basically doing what @simlu suggested. |
Also seeing this issue. |
I only used the |
@simlu yes it's work by put type Query in typeDefs and then put it in ApolloServer |
We experience the same problem, we are using remote schema stitching and one of services we merge with doesn't have a queries, it has only mutations. |
until this is resolved some other way, I added then, after stitching:
and now there is no more exposed There should still be a better way to do this. |
Guys any plan in roadmap to fix this? |
:D hahahaha it is insane :D I am trying to build schema based on Types only, so i can use it to build more complex relations out of it and pass it to Neo4J graph database.Instead i need to define Root query which will not be used for anything. Basically i decided to create https://github.com/rxdi/neo4j/blob/master/src/services/util.service.ts#L52 createRootSchema() {
const directives =
this.gqlConfig.directives || this.config.directives || [];
return new GraphQLSchema({
query: new GraphQLObjectType({
name: "status",
fields: {
status: {
type: GraphQLString,
resolve: () => ({status: 200})
}
}
}),
directives,
types: this.typeService.types || []
});
} I would love to transfer it to this createRootSchema() {
const directives =
this.gqlConfig.directives || this.config.directives || [];
return new GraphQLSchema({
directives,
types: this.typeService.types || []
});
} If i don't define root query this schema is invalid. But i would like to just build schema based on type definition and then just print it out so i can work with the types for further more extending capabilities . Regards! |
so.. any plans to fix this? 😞 |
+1 |
bump |
1 similar comment
bump |
Try this one, It might help you out.. const { ApolloServer, gql } = require("apollo-server"); const todos = [{ task: "Open the door", completed: true }]; const typeDefs = gql` type Query { const server = new ApolloServer({ typeDefs }); |
still not fixed type Query {
hello: String!
} works fine type Mutation {
test: String!
} throws error |
This cannot be "fixed" without changing overall design. Schema stitching is working as intended in this scenario, the "bug" is that core graphql does not allow schemas without a root query type. See above workarounds by @simlu and @derekpitt. It might look cleaner to expose a __version or __servicename or __status field instead of __dummy in the service, but nothing has to be exposed after stitching if transforms are used per @derekpitt. You can also try the FilterRootFields transform which just uses TransformRootFields under the hood. |
there are a lot of other types besides of Query. Mytations, enums, Input whad makes Query so special? |
That is issue for upstream graphql-js reference implementation |
Closed with this comment: graphql/graphql-js#448 (comment) |
Can be tracked at spec at graphql/graphql-spec#218 and graphql/graphql-spec#490 |
I'm still getting this error with v4.0.8 and have to use |
There is still the issue if you try to stitch a schema that contains no queries, in my case a specific schema contains only subscriptions. Adding dummy query as previous comments suggested makes it work properly. Using graphql-tools v7.0.2 |
@Spolja schema stitching uses GraphQLJS and GraphQLjs needs a query root type provided, so I don't think we can fix that on our side. |
@ardatan, |
I am also getting this issue doesn't anybody have working solution?? |
Until a better solution is known, I resolved it by adding |
Discription
I am trying to stitch two schemas that one of them only contains a Mutation type using the latest
graphql-tools
v3.0.0. The error will disappear if any Query type contains more than one field is added to the single-mutation schema.Since the error is not the same as #659 and that issue has been a while before the v3.0.0 was out, I open this issue. Please close this if you think this is duplicate.
Related issue: #659
Related PR: #746
Intended outcome
Querying Mutation test field should return a string result.
Actual outcome
"Query root type must be provided." error is returned.
How to reproduce the issue
First schema:
Second schema:
Query:
returned data:
The text was updated successfully, but these errors were encountered: