Why this fragment makes this object null
and the query not?
#2103
-
I have a reproduction: https://github.com/frederikhors/iss-urql-fragment-null-obj 😃😃😃😃 The problemWhen you navigate to When you navigate to If you goback to If you change the team {
...TEAM_FRAGMENT
} to The steps
The gifOriginal questionIf I use the below code it doesn't work, the second query ( fragment PLAYER on Player {
id
createdAt
team {
...TEAM
}
}
fragment TEAM on Team {
id
createdAt
}
query player($id: ID!) {
player(id: $id) {
...PLAYER
}
}
query team($id: ID!) {
team(id: $id) {
...TEAM
player {
...PLAYER
}
}
} The code below addresses the issue (this is the only change I do in my code base): fragment PLAYER on Player {
id
createdAt
# removed these lines from here:
# team {
# ...TEAM
# }
}
fragment TEAM on Team {
id
createdAt
}
query player($id: ID!) {
player(id: $id) {
...PLAYER
# to here:
team {
...TEAM
}
}
}
query team($id: ID!) {
team(id: $id) {
...TEAM
player {
...PLAYER
}
}
} My question is: why it works in queries and not in fragments? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 14 replies
-
Sorry if I poke you guys, @JoviDeCroock @kitten (I'm in production with this mess), I can't even create a working codesandbox because it's really a mess to make them work there (I tried, really, you know me). Have you ever had a fragment with an internal fragment that made an object |
Beta Was this translation helpful? Give feedback.
Sorry if I poke you guys, @JoviDeCroock @kitten (I'm in production with this mess), I can't even create a working codesandbox because it's really a mess to make them work there (I tried, really, you know me).
Have you ever had a fragment with an internal fragment that made an object
null
and instead using that same fragment in a query works (object notnull
)?