We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
I'm trying to flatten fragments in my response models, but I'm encountering an issue where the fragments are wrapped in a nested object.
Here’s the GraphQL query I’m using:
fragment AuthenticationFragment on SessionInfo { role sessionGUID token } mutation loginAsGuest { login( lang: { key: "FRA" } ) { ...AuthenticationFragment } }
The expected response (from a GraphQL client like Postman) is:
{ "data": { "login": { "role": "XXX", "sessionGUID": "XXX", "token": "XXXX" } } }
However, when using the Apollo Java Client, the response looks like this:
{ "login": { "__typename": "SessionInfo", "authenticationFragment": { "role": { "rawValue": "XXX" }, "sessionGUID": "XXX", "token": "XXX" } } }
As you can see, the fields of the AuthenticationFragment are nested inside the authenticationFragment object.
How can I remove the authenticationFragment wrapper and directly flatten the fields (role, sessionGUID, token) into the login object?
I have tried enabling the flattenModels option in the plugin configuration, but it didn’t work as expected.
Any missing configuration ? Below my configuration :
<plugin> <groupId>com.github.aoudiamoncef</groupId> <artifactId>apollo-client-maven-plugin</artifactId> <version>7.1.0</version> <executions> <execution> <goals> <goal>generate</goal> </goals> <configuration> <services> <test-api> <enabled>true</enabled> <addSourceRoot>true</addSourceRoot> <sourceFolder>${project.basedir}/src/test/resources/test</sourceFolder> <schemaPath>${project.basedir}/src/test/resources/test/schema.graphql </schemaPath> <includes> <include>**/*.gql</include> </includes> <compilationUnit> <name>test</name> <generateOperationDescriptors>true</generateOperationDescriptors> <compilerParams> <rootFolders> <rootFolder>${project.basedir}/src/test/resources/test/</rootFolder> </rootFolders> <scalarsMapping/> <schemaPackageName>fr.test.apollo.client</schemaPackageName> <packageName>fr.test.apollo.client</packageName> <codegenModels>OPERATION</codegenModels> <flattenModels>true</flattenModels> <generateApolloMetadata>false</generateApolloMetadata> <generateAsInternal>false</generateAsInternal> <generateFilterNotNull>false</generateFilterNotNull> <generateFragmentImplementations>false</generateFragmentImplementations> <generateKotlinModels>false</generateKotlinModels> <generateOptionalOperationVariables>false</generateOptionalOperationVariables> <generateQueryDocument>true</generateQueryDocument> <generateResponseFields>false</generateResponseFields> <generateSchema>false</generateSchema> <generateTestBuilders>false</generateTestBuilders> <generateDataBuilders>false</generateDataBuilders> <generateModelBuilders>false</generateModelBuilders> <nullableFieldStyle>NONE</nullableFieldStyle> <useSemanticNaming>true</useSemanticNaming> <targetLanguage>JAVA</targetLanguage> <sealedClassesForEnumsMatching></sealedClassesForEnumsMatching> <alwaysGenerateTypesMatching></alwaysGenerateTypesMatching> <metadataOutputFile> ${project.build.directory}/generated/metadata/apollo/test/metadata.json </metadataOutputFile> </compilerParams> </compilationUnit> </test-api> </services> </configuration> </execution> </executions> </plugin>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi,
I'm trying to flatten fragments in my response models, but I'm encountering an issue where the fragments are wrapped in a nested object.
Here’s the GraphQL query I’m using:
The expected response (from a GraphQL client like Postman) is:
However, when using the Apollo Java Client, the response looks like this:
As you can see, the fields of the AuthenticationFragment are nested inside the authenticationFragment object.
How can I remove the authenticationFragment wrapper and directly flatten the fields (role, sessionGUID, token) into the login object?
I have tried enabling the flattenModels option in the plugin configuration, but it didn’t work as expected.
Any missing configuration ?
Below my configuration :
The text was updated successfully, but these errors were encountered: