Return Map from GraphQL (#11966)

* Return Map from GraphQL

Three techniques have been used

1. Return as Json String
2. Return Json using GraphQL scalar type
3. Return as list of key-value pair

* Adding custom scalar in plugin configuration

* Build failure fix
1. Integrating the .graphqls files
2. Updating the respective query resolvers

* Build failure Fix

1. Removed the extra .graphql file

2. Added ExtendedGraphQLScalarType class because the parent class didn't 
have default constructor and the client code generation plugin was 
requiring it.

* Code refactoring

* Code refactoring
This commit is contained in:
Muhammad Abdullah Azam Khan
2022-04-21 16:01:36 +04:00
committed by GitHub
parent 936055fd69
commit ce2839b058
13 changed files with 398 additions and 1 deletions
+33 -1
View File
@@ -36,6 +36,21 @@
<artifactId>graphql-java-annotations</artifactId>
<version>${graphql-java-annotations.version}</version>
</dependency>
<dependency>
<groupId>io.ratpack</groupId>
<artifactId>ratpack-core</artifactId>
<version>${ratpack-core.version}</version>
</dependency>
<dependency>
<groupId>com.github.americanexpress.nodes</groupId>
<artifactId>nodes</artifactId>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
<version>11.0</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-tools</artifactId>
@@ -95,6 +110,14 @@
<version>${mockserver-client-java.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-extended-scalars</artifactId>
<version>${graphql-java-extended-scalars.version}</version>
</dependency>
</dependencies>
<build>
@@ -133,6 +156,13 @@
<copyRuntimeSources>false</copyRuntimeSources>
<generateDeprecatedRequestResponse>false</generateDeprecatedRequestResponse>
<separateUtilityClasses>true</separateUtilityClasses>
<customScalars>
<customScalar>
<graphQLTypeName>JSON</graphQLTypeName>
<javaType>java.util.Map</javaType>
<graphQLScalarTypeClass>com.baeldung.graphqlreturnmap.ExtendedGraphQLScalarType</graphQLScalarTypeClass>
</customScalar>
</customScalars>
</configuration>
</plugin>
</plugins>
@@ -154,6 +184,8 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<graphql.java.generator.version>1.18</graphql.java.generator.version>
<graphql-java-extended-scalars.version>2022-04-06T00-10-27-a70541e</graphql-java-extended-scalars.version>
</properties>
</project>
</project>