-
Notifications
You must be signed in to change notification settings - Fork 45
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
Handling duplicate "Query" and "Mutation" types #92
Comments
This would be addressed in the GQL plugin. @Mayank1791989 this usecase is what we were discussing about today, no? |
I thought that might be the case. Should I open this same issue over there? |
We only support the official graphql spec and according to spec you can't have two type definition with same name. If you can change how you write graphql files then there are two options
# post.graphql
type Post {
id: String!
name: String!
}
extend type Query {
posts: [Post!]
}
extend type Mutation {
addPost(name: String!): Post!
} # user.graphql
type User {
id: String!
name: String!
}
extend type Query {
users: [User!]
}
extend type Mutation {
addUser(name: String!): User!
}
# post.graphql
type Post {
id: String!
name: String!
} # user.graphql
type User {
id: String!
name: String!
} # query.graphql
type Query {
posts: [Posts!]
users: [User!]
} # mutation.graphql
type Mutation {
addPost(name: String!): Post!
addUser(name: String!): User!
} |
It appears the first option doesn't work with merge-graphql-schema (or I'm doing something wrong). I opened an issue there. The second option will do for now. Thanks for the quick replies! |
@kumarharsh Has this been "addressed" by the GQL plugin as mentioned some months back now? This is still a detrimental issue that doesn't play well with a common pattern. |
Both options doesn't work for me since I'm using merge-graphql-schema too and extending types just fail and my main Mutation object is generated by Prisma :-( I actually want to extend Prisma entities and mutations with authorization directives. There's no way currently to just deactivate "unique named types" check? |
I'm using a file structure which I believe is common. I have multiple files like "Post.graphql" and "User.graphql", each with their own distinct types. But, each also has a "Query" and "Mutation" type. I use merge-graphql-schemas to merge them together, which works fine functionally.
But, with this plugin I'm getting this linting error:
Similarly for "Mutation".
Aside from changing my structure such that all the queries and mutations are in the same file, how can I work around this error?
The text was updated successfully, but these errors were encountered: