Dgraph GraphQL Tour
Adding schema - mutating schema
As you saw in an earlier lesson, Dgraph accepts a GraphQL schema comprised of types to generate the GraphQL API.
The GraphQL API is a strictly-typed API. You can only add and query data that matches a predefined schema. However, do not let this limitation restrict you from iterating on the schema as needed.
Normally, in GraphQL implementations you would have to define inputs, queries, and mutations in the GraphQL schema being deployed. Dgraph generates all of these for you. All that you need to do is to define your types.
For Dgraph to correctly generate the correct GraphQL API, you need to supply the complete GraphQL schema with every schema update. This does not mean that you need to provide the inputs, queries, and mutations; but it does mean that if you leave out a type on a schema update, then that part of the API will cease to exist, even though the underlying data remains unchanged.
The example schema shown here iterates on our previous schema by adding
additional fields on the type
Person and adding the type
Company. In this
section, you will learn more about these schema changes and what you can do with
a more complex schema.
Push this new schema to the server, and then continue to the next step.