-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Feedback for “Schemas and Types”; Why is a "Query" considered a "type"? #1825
Comments
Alternatively, type Character { operation Query { |
The reason that the # This is the `query` root operation type
type Root {
randomVirus: Virus
}
type Virus {
name: String!
knownMutations: [Mutation]
}
# This is NOT the `mutation` root operation type, as defined below
# this schema does not support the `mutation` operation type.
type Mutation {
name: String!
}
schema {
query: Root
} Here's the relevant part of the GraphQL specification if you're inclined to read further: |
Another way to think about it is in terms of graph traversal (see my blog post on this topic) - the |
It is more of a fundamental question in terms of naming some artifacts of a GraphQl system.
Why is a "Query" considered a "type"? It is hard for me to conceptualize the following two declarations in the same specification because their essential nature and semantics are different:
type Character {
name: String!
appearsIn: [Episode!]!
}
type Query {
droid(id: ID!): Droid
}
Character describes the type (composition) of a data object whereas Query is an operation. Conceptually, Query, Mutation, and Subscription are "operations" - not "types".
Why are we overloading the term "type" to specify the "composition of a data object" as well as an "operation"?
Saying the following may be more appropriate if we have to use the term "type":
objectType Character {
name: String!
appearsIn: [Episode!]!
}
operationType Query {
droid(id: ID!): Droid
}
Maybe you can explain it in a way that avoids this conceptual confusion between the "composition of a data object" and an "operation" indicated by the same term "type".
The text was updated successfully, but these errors were encountered: