Skip to content

Commit

Permalink
Update documentation for new graphql-java-tools example
Browse files Browse the repository at this point in the history
  • Loading branch information
sachindshinde committed Apr 18, 2021
1 parent 430d65c commit 9489327
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
7 changes: 6 additions & 1 deletion spring-example/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
This Spring Boot application contains examples for both a microservice using standard `graphql-java` and a microservice using `graphql-java-tools`; their code is separated under different subpackages and Spring profiles.

To run the example, cd to the root of this project, then...
To run the standard `graphql-java` example, `cd` to the root of this project, then...
```
## compile and install project including example and dependencies
mvn install -Dgpg.skip
## start local webserver on 9000
mvn -pl spring-example spring-boot:run
```
To run the `graphql-java-tools` example, for the last step instead run:
```
mvn -pl spring-example spring-boot:run -Dspring-boot.run.profiles=graphql-java-tools
```
Now you can query your local graph:
```
## e.g.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* Some tips for running with graphql-java-tools:
* 1. You may find that graphql-java-tools removes types that are only used by the federation
* _entities field. This is because graphql-java-tools performs these optimizations before
* federation-graphql-java-support can alter the schema to include the _entities field. The
* simplest workaround here is to both (1) add the type to the {@link SchemaParserDictionary}
* bean and to (2) set the {@link SchemaParserOptions.Builder} bean to have includeUnusedTypes
* as true. However, the latter can't be done via properties.xml/yml since the getters/setters
* aren't named according to the JavaBeans API specification (i.e. getFoo()/setFoo()). You can
* work around this by providing the whole bean via code, or using a {@link BeanPostProcessor}
* as shown below to customize the auto-configuration bean.
* 2. If you have an empty query type, you don't need to add a dummy field to your
* {@link graphql.kickstart.tools.GraphQLQueryResolver} or to your schema string. However, you
* do need to (1) declare an empty {@link graphql.kickstart.tools.GraphQLQueryResolver}, (2)
* declare an empty "type Query" in your schema string, and (3) setup {@link SchemaTransformer}
* as shown below. We could potentially modify the federation-graphql-java-support API to accept
* {@link GraphQLSchema.Builder}s, but unfortunately those builders have no public getters, so
* we wouldn't be able to copy their data.
*/
@Configuration
public class GraphQLJavaToolsConfiguration {
@Bean
Expand Down

0 comments on commit 9489327

Please sign in to comment.