Skip to content

Latest commit

 

History

History
37 lines (24 loc) · 1.18 KB

07-graphql-schema-interfaces.md

File metadata and controls

37 lines (24 loc) · 1.18 KB

Interfaces

In GraphQL, the server developer can use an interface, which defines a set of fields.

For example, you could have a Name interface defined on the server like this:

interface Name {
  firstName: String!
  lastName: String!
}

Any type that implements that interface must include those exact fields with the same types.

In a request, you can ask for a field that is of an interface type:

  1. In the Github GraphiQL, ask for a node field with an id of:

    MDQ6VXNlcjU3MjQzNw==.

    This field has subfields, so ask for the id subfield.

  2. How many subfields does the Node interface have?

  3. How many non-scalar types are there on this server (approximately)? Use GraphiQL's Documentation Explorer to drill down from the top-level Query type.

  4. Which of these types implement the Node interface? To find out, navigate to Node and look at the list of types implementing it.

  5. So if you request a data item of type Node, how many different types could you potentially receive? What are some example types?

  6. Can you add the fields of any of those concrete types to your query?