Kaanixir
01/15/2024, 1:27 AMmutation
which includes a fragment model inside, something like:
query getX($deviceBla: ID!) {
getX(deviceBla: $deviceBla) {
...getY
}
}
and getY is something like:
fragment getY on X
I'm trying to feed a manually generated response from the Apollo Mock Server back to the Apollo Client.
In original prod, without the mock server, the entire response on getX returns with getY fragment being replaced with it's inner fields. So getY 's Y class fields gets merged onto X response model
But the Query Model itself in kotlin, via adapter, is generated as
Data(getX) : Query.Data
public data class GetX(__typename: String, val getY: Y)
so if I build the response via response builders, or if I build it myself, I end up having to initialise the Y inside getX's response model, and JSON ends up having the key value for Y, when in reality key value for Y is not supposed to be there because fragment replaces the class with it's inner fields and merges it into the upper parent.
How can we manually or via response_builders, generate a more complex graphql response like this ? the only difference is Y's inner field methods are merged onto the parent model, I thought this would be easy to achieve, or I expected response builders to intelligently tackle thisbod
01/15/2024, 9:36 AM{"data": {"getX": {"y": {...} } } }
.
> How can we manually or via response_builders
Are you referring to the data builders or something else?KaaN
01/16/2024, 12:36 AMdata builders
by response builders - I'm trying to JSON serialise these responses but they're not in the structure that they're expected, when I send these responses from mock server to the apollo client.
The JSON doesn't end up being a flat structure (fragment model's fields are supposed to be merged onto the parent object) but the resulting JSON of the data builder's response builds the Data models of the queries, there is no response model generation. Data builders seem to generate the queries, not the responses - or I'm missing something here
the response structure is not the expected, flat structure that includes the fields of the fragment inside the response, maybe I'm initialising the wrong Data model 😕bod
01/16/2024, 8:43 AM