Skip to content

Commit d1c1c7b

Browse files
author
EtienneSF
committed
Comm' ready for first publication
1 parent 4baa6cc commit d1c1c7b

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

README.md

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
# GraphQL Java Generator
22

3-
TODO: remove need to graphql-java-client from the server (needed because of the annotations)
4-
53

64
The GraphQL Java Generator makes it easy to work in Java with graphQL in a schema first approach.
75

8-
This project is an accelerator to develop <B>GraphQL clients</B> and <B>GraphQL servers</B> in java. That is: it generates the boilerplate code, and let you concentrate on what's specific to your use case: the queries/mutations/subscriptions you will call, when in client mode. And the response to the queries/mutations/subscriptions call, as well as the relations between objects, when in server mode.
6+
This project is an accelerator to develop __GraphQL clients__ and __GraphQL servers__ in java. That is: it generates the boilerplate code, and let you concentrate on what's specific to your use case: the queries/mutations/subscriptions you will call, when in client mode. And the response to the queries/mutations/subscriptions call, as well as the relations between objects, when in server mode.
97

10-
* The <B>GraphQL client</B> generated by graphql-java-generator contains a class for each query and mutation type. Subscription are not managed yet. These classes contains a metod for each field of the query and mutation types. To call the GraphQL server, you just call one of this method. The <B>GraphQL response is contained in POJOs</B>, for easy use in Java.
11-
* The <B>GraphQL server</B> contains the heart of the GraphQL server: The main method (if you use it as a Spring Boot application), the declaration of each Data Fetcher, and the listening of incoming calls, as well as the forging of the Response. The developper has 'only' to develop the Data Fetchers, that is: the link with the underlying data. The generated POJOs are annotated with JPA annotations, so it's pretty easy to map with Spring Data.
8+
* The __GraphQL client__ generated by graphql-java-generator contains a class for each query and mutation type. Subscription are not managed yet. These classes contains a method for each field of the query and mutation types. To call the GraphQL server, you just call one of this method. The __GraphQL response is contained in POJOs__, for easy use in Java.
9+
* The __GraphQL server__ contains the heart of the GraphQL server: The main method (if you use it as a Spring Boot application), the declaration of each Data Fetcher, and the listening of incoming calls, as well as the forging of the Response. The developer has 'only' to develop the Data Fetchers, that is: the link with the underlying data. The generated POJOs are annotated with JPA annotations, so it's pretty easy to map with Spring Data.
1210

13-
Please, take a look at the projets that are within the graphql-maven-plugin-samples: they show various ways to implement a GraphQL server, based on the graphql-java library.
11+
Please, take a look at the projects that are within the graphql-maven-plugin-samples: they show various ways to implement a GraphQL server, based on the graphql-java library.
1412

15-
<B>The interesting part is that graphql-java-generator is just an accelerator: you don't depend on additional library</B>. So, it just helps you.
13+
__The interesting part is that graphql-java-generator is just an accelerator: you don't depend on additional library__. So, it just helps you to build application based on [graphql-java](https://www.graphql-java.com) .
1614
If the generated code doesn't fully suit your needs, you can: take what's generated as a full sample for graphql-java usage, based on your use case. You can then update the generated code, where it's not compliant for you. And that's it. The only thing, there, is that we would like to know what was not correct for your use case, so that we can embed it into next versions. Or perhaps it's just a matter of documentation, to better explain how to use it...
1715

18-
The generator is currently a maven plugin. A Gradle plugin will come.
16+
The generator is currently available as a maven plugin. A Gradle plugin will come soon.
1917

2018

2119
## Aim of this projet
2220

2321
The aim of this project is to:
2422

2523
* Hide all the GraphQL technical stuff and boilerplate code
26-
* Let the developper concentrate on his applicaiton
24+
* Let the developer concentrate on his application
2725
* Make it __very easy__ to create a GaphQL client, based on the generated POJOs. The calls to the GraphQL server are just the call of a generated Java method, with Java parameters
28-
* Make it __easy__ to create a GraphQL server. The plugin generated the server boilerplate code and the POJOs. But it's still up to the developper to map the GraphQL schema to the database schema. See the provided samples for different ways to do this. The generated code integrate the JPA schema, making the database access easy, thanks to the Spring Data Repositories.
26+
* Make it __easy__ to create a GraphQL server. The plugin generated the server boilerplate code and the POJOs. But it's still up to the developer to map the GraphQL schema to the database schema. See the provided samples for different ways to do this. The generated code integrate the JPA schema, making the database access easy, thanks to the Spring Data Repositories.
2927

3028
In the near future :
3129
* Implement also Mutations and Subscriptions. Currently only queries are managed.
@@ -109,7 +107,7 @@ When the package type of the maven module (or project) is _jar_, then this mode
109107
The server mode is more complex, as its subject is to link the GraphQL schema to the underlying data structure. This data structure can vary a lot (relational database with lots of possible physical schema, document database like MongoDB, underlying JSON services...). Of course, the generated code can not guess what's your data structure, and how to access it.
110108

111109
So the GraphQL Java Generator generates:
112-
* The GraphQLServer class, wich is the executable Java class. It's actually a Spring Boot application.
110+
* The GraphQLServer class, which is the executable Java class. It's actually a Spring Boot application.
113111
* TODO: in the future, it will also be possible to generate war packages.
114112
* The code expected by the graphql-java library. It depends on no other graphql dependency
115113
* The POJOs, so that you can manipulate your data.
@@ -127,20 +125,20 @@ The build will complain about the Data Fetchers Delegate you need to define.
127125

128126
A Data Fetcher Delegate is a class that implements a XxxDataFetcherDelegate. It is responsible to return the data, as specified in the GraphQL schema. Of course, for mutation, it needs to do some complementary work.
129127

130-
<B>Important:</B> a DataFetcherDelegate is a Spring component. That is, in order to Spring to find it, it must implement the @Component Spring stereotype annotation.
128+
__Important:__ a DataFetcherDelegate is a Spring component. That is, in order to Spring to find it, it must implement the @Component Spring stereotype annotation.
131129

132130
The Data Fetcher Delegates are the heart of the Server part.
133131

134132
The short story is this one:
135133
* The code generated by the GraphQL maven plugin directly maps to the entity, thanks to [Spring Data JPA](https://spring.io/projects/spring-data-jpa)'s magic.
136-
* The developper still needs to develop the DataFetchers, to manage the relation between objects (see the samples and below, to see how to do this).
134+
* The developer still needs to develop the DataFetchers, to manage the relation between objects (see the samples and below, to see how to do this).
137135

138136
A longer story is this one:
139137
* The GraphQL maven plugin expects a database model that is the same as what's in the GraphQL schema. That is: for each GraphQL object, there is a
140138
table with the same name, and for each field of each of these GraphQL objects, there is a column with the same name and type. This insure the JPA
141139
access to the database.
142140
* In GraphQL request, a critical factor for performance is the way to query relations between objects. The [graphql-java site](https://www.graphql-java.com/documentation/v12/batching/)
143-
is very clear on this subject. So the maven plugin mark every relational field as transient, and let the developper manage these relations.
141+
is very clear on this subject. So the maven plugin mark every relational field as transient, and let the developer manage these relations.
144142

145143
So you have to create the Data Fetchers. Please, take a look at the projets that are within the graphql-maven-plugin-samples: they show various ways to implement a GraphQL server, based on the graphql-java library. The interesting part is that graphql-java-generator is just an accelerator: you don't depend on additional library.
146144

@@ -180,19 +178,18 @@ You can access to the H2 Console with this URL: [http://localhost:8180/h2-consol
180178

181179
You'll find below the main changes, that are foreseen in the near future
182180
- Manage Subscriptions. Currently, GraphQL Java Generator manages queries and mutations.
183-
- Generate the package as a jar or war form. Currently, GraphQL Java Generator generates a Spring Boot application.
184181
- Add a gradle plugin
185-
- Manage properties which name is a java keyword, like: public, private, class...
186-
- Manage field parameters. Currently, GraphQL Java Generator accepts parameters out of the query level (that is on object fields), only wih Direct Queries (which is nice enough to begin)
187-
- Comments should be reported in the generated code, especially the POJOs and the queries, mutations and subsciptions
182+
- Manage properties which name are java keyword, like: public, private, class... Currently, it would generate a compilation error.
183+
- Manage field parameters. Currently, GraphQL Java Generator accepts parameters out of the query level (that is on object fields), only with Direct Queries (which is nice enough to begin)
184+
- Comments should be reported in the generated code, especially the POJOs and the queries, mutations and subscriptions
188185
- Define specific Scalars (for instance Date, DateTime, Time)
189186
- The plugin currently manages only one schema. It would be nice to allow several graphqls files, with a pattern like /*.graphqls
190187
- Fragment in graphql queries
191188

192189

193190
### Note for contributors
194191

195-
This projet is a maven plugin project.
192+
This project is a maven plugin project.
196193

197194
If you want to compile it, you'll have to add the lombok.jar file in your IDE. Please see the relevant section, in the Install menu of the [https://projectlombok.org/](https://projectlombok.org/) home page. This very nice tools generates all java boiler plate code, like setters, getters, constructors from fields...
198195

0 commit comments

Comments
 (0)