Replies: 15 comments 4 replies
-
Not to sure what you mean. Are you sure this is allowed in the spec https://spec.graphql.org/draft/ ? |
Beta Was this translation helpful? Give feedback.
-
Yes in the spec it is referred as MyQueryRootType and MyMutationRootType and having several of those e.g. CustomerRootType, UserRootType and all queries related to customer will go under CustomerRootType and all queries related to user will go under UserRootType. |
Beta Was this translation helpful? Give feedback.
-
Can you share a link ? |
Beta Was this translation helpful? Give feedback.
-
Sure, here it is: https://spec.graphql.org/draft/#sec-Schema |
Beta Was this translation helpful? Give feedback.
-
That is just naming the roots, not have mulitple, right ? We hardcode the root (query, mutation, subscription) and can maybe allow you to name them, but as far as I can see you still only have those 3. Or am I missing something ? |
Beta Was this translation helpful? Give feedback.
-
In that case is there a way to define multiple schemas? |
Beta Was this translation helpful? Give feedback.
-
Can you even specify multiple roots for an operation type?
Is this legal? It's not clear to me from the spec. It doesn't say whether the same |
Beta Was this translation helpful? Give feedback.
-
No that is not legal as far as I know. We did "hack" this with our "group feature" a while back, but that will be removed as this is really hacky and against the spec. |
Beta Was this translation helpful? Give feedback.
-
But as I said this will probably be removed in a future version |
Beta Was this translation helpful? Give feedback.
-
And is it possible to have some groupings with the help of Type?
And then the actual queries and GraphQLApi will be defined within these types? |
Beta Was this translation helpful? Give feedback.
-
If you have two queries in your code, one for customers and one for User you should get that. |
Beta Was this translation helpful? Give feedback.
-
Like this?
That I think is legal, but we don't provide a way to do this. It would also make querying a bit complicated because you would have to include the 'group' name in the query
|
Beta Was this translation helpful? Give feedback.
-
@jmartisk yes this is exactly what I was looking for. Yes querying will be more complex, but navigating through the schema in large scale projects will be much easier. |
Beta Was this translation helpful? Give feedback.
-
Well the other option is to break up your app in multiple apps... or the grouping feature would give you what you want, or basically an empty object (customers) that only has source fields on ... But I would not optimize for easy schema reading. The main purpose for the schema is not to make it readable for humans. By naming your queries properly, the user can still navigate the schema easily. |
Beta Was this translation helpful? Give feedback.
-
I am going to move this to a discussion rather than an issue |
Beta Was this translation helpful? Give feedback.
-
Hello,
Currently when adding @GraphQLAPI class with @query and @mutation methods and having multiple of these at the end in the generated schema all of the queries and mutations are grouped under Query root and Mutation root.
It would be nice to be able to group them logically by some context/name as it can be done in the schema first approach with separate schema files.
Beta Was this translation helpful? Give feedback.
All reactions