agrosner
07/12/2023, 9:27 PMmbonnin
07/12/2023, 9:34 PMmbonnin
07/12/2023, 9:36 PM{
animal {
species
name
}
}
You will get a model matching Animal
irrespective of the different concrete types (Lion
, Turtle
, etc...)agrosner
07/12/2023, 10:19 PMagrosner
07/12/2023, 10:20 PMagrosner
07/12/2023, 10:20 PMmbonnin
07/12/2023, 10:23 PMagrosner
07/12/2023, 10:24 PMagrosner
07/12/2023, 10:24 PMmbonnin
07/12/2023, 10:26 PMmbonnin
07/12/2023, 10:26 PM{
node {
id
... on Animal {
species
}
}
}
mbonnin
07/12/2023, 10:27 PMCat
then the backend knows it's a Animalmbonnin
07/12/2023, 10:28 PM{
"animal": {
"__typename": "Cat",
"id": "42",
"species": "Cat"
}
}
mbonnin
07/12/2023, 10:28 PMspecies
mbonnin
07/12/2023, 10:28 PMmbonnin
07/12/2023, 10:29 PMagrosner
07/14/2023, 1:30 PMnode
query that references an interface vs a concrete type that has an interface field?mbonnin
07/14/2023, 1:31 PMagrosner
07/14/2023, 1:32 PM{
animal {
id
eyes {
color
}
}
}
If Animal
was concrete field type, then a field named eyes
was an interface with color
field.mbonnin
07/14/2023, 1:32 PMagrosner
07/14/2023, 1:32 PMtype DefaultEyes implements Eyes
but backend decides to send type BrownEyes implements Eyes
, then it should workmbonnin
07/14/2023, 1:33 PMeyes
fieldmbonnin
07/14/2023, 1:33 PMagrosner
07/14/2023, 1:34 PMeyes {
color
... on DefaultEyes {
anotherField
}
}
app would still see color, is my thought. if im understanding correctly. which is perfectly fineagrosner
07/14/2023, 1:34 PMmbonnin
07/14/2023, 1:36 PMapp would still see color, is my thought. if im understanding correctly. which is perfectly fineYep, exactly. Every subfield of the given field ("just under") will be still be seen. But not always for fields that are nested in fragments
agrosner
07/14/2023, 1:37 PM