Description
This is truly a complicated one.
I have this graphene node
class TripNode(DjangoObjectType):
legs = List(LegNode)
# Need explicit pk when forming TripNode manually and querying for id
pk = String(source="id")
class Meta:
model = Trip
interfaces = (relay.Node,)
The resolver fetches some remote data and resolves legs
there since legs
is derived from that remote data as well.
def resolve_trips(root, info, **kwargs):
response = requests.get("")
return [
TripNode(
**{
"id": uuid.uuid4(),
"origin": trip["origin"],
"legs": [
TripLeg(
origin_hub=leg["flyFrom"],
id=uuid.uuid4(),
)
for leg in trip["route"]
],
}
)
for trip in response.json()["data"]
]
Usually I would instead return a list of Trip
s but I can't use the Django model here because I am resolving the extra field legs
that does not exist in the model. One reason it doesn't is that it must be ordered so a one-to-many field would not suffice without some addition.
If I do return a list of Trips
without legs
, it works fine and the client doesn't overwrite the previous query results with the new ones. But that weird overwrite behavior does occur when I use TripNode
instead, and that's the only difference. Therefore I am making the issue here instead of in the client repo (relay) because I think it has to do with some graphQL standard not being respected in this case.
I'm pretty much at a loss for what's going on and would appreciate any thoughts.