In graphql what is difference between a type query and extend type query?
Ex: difference between
type Query {
product(id: String!): Product
}
and
extend type Query {
DeviceDetail(devId: String!): DeviceDetail
}
Will appreciate if you could add an example for your explanation.
Object extension is supported by the GraphQL spec as a way to add new properties to an existing type.
In this case, you will find
extend type Queryin some schemas as a way to "modularize" a schema, for example:in
schema.graphqls:in
book.graphqls:Without this, you would need to either declare all queries in the same schema file, or you would get an error when GraphQL parses the schema files as the
Querytype is defined several times.Other apps use "namespacing" as a way to better organize the schema and avoid flattening all queries under the same type.