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:
-
In the Github GraphiQL, ask for a
node
field with anid
of:MDQ6VXNlcjU3MjQzNw==
.This field has subfields, so ask for the
id
subfield. -
How many subfields does the
Node
interface have? -
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. -
Which of these types implement the
Node
interface? To find out, navigate toNode
and look at the list of types implementing it. -
So if you request a data item of type
Node
, how many different types could you potentially receive? What are some example types? -
Can you add the fields of any of those concrete types to your query?