-
On the Github API, try running a query like this. Should it execute?
{ node(id: "U_kgDOAAi8FQ") { id __typename login name } }
-
We asked for an interface type (
Node
), and even though it may have returned aUser
, we can't retrieve that User'slogin
orname
, because they're not defined onNode
, the interface type.To include fields based on their runtime type, we can use fragments.
-
Create a fragment to query the
login
andname
fields, and then 'call' it from your query using the spread operator. What happens? -
Run the same query and fragment again, but with a different
id
(egO_kgDOAA3wnw
) that retrieves a different type. What response do you get? Do you get an error? -
How could you retrieve a
login
andname
if aUser
is returned, but adescription
,name
andlocation
if anOrganization
is returned? Try it.