Comments (8)
I was not able to find a solution for client-side code generation in Java.
Yes, I was actually mentioning code generators in general.
The one I heard about was for Swift I think.
The idea of this feature would be:
- Define the projection of the response object (which fields to fetch)
- Properly serialize the request.
Oh OK, so you want to build client queries in Java directly?
That could be a way too, I just felt like the idea of this library was to go schema-first, so I expected a query-first solution here. But that implies parsing queries. I don't know if the library you're using can do this.
from graphql-java-codegen.
from graphql-java-codegen.
@joffrey-bion
I was not able to find a solution for client-side code generation in Java.
The idea of this feature would be:
- Define the projection of the response object (which fields to fetch)
- Properly serialize the request.
So the code on the client-side will look like:
BikeInputTO input = new BikeInputTO(...);
NewBikeMutationRequest request = new NewBikeMutationRequest(input)
.responseProjection(new BikeProjection()
.id().addedDateTime());
Bike bikeResponse = restTemplate.postForObject("https://localhost:8080", request, Bike.class);
(the DSL is still discussable)
from graphql-java-codegen.
Oh OK, so you want to build client queries in Java directly?
Yes. But the approach will still be schema-first because the client will use schema to generate the request and response classes.
The main problem that I am facing in one of my projects is to serialize the request. Because GraphQL request is not a JSON and I can't find a proper GraphQL request serialization in java.
from graphql-java-codegen.
Hi @kobylynskyi that's exactly what I was thinking about and thanks for raising this feature, I initially thought that the graphql-codegen-maven-plugin plugin did generate client code as it generates classes that do seem to map to the response class :-), A new feature the way you have illustrated above would be very handy. Ultimately, all I'd like to is to be able to run a GraphQL query by building a request in Java and interrogate the response (similar to the swagger-codegen-maven-plugin). Schema first is critical as it dynamically creates the classes when changes to the schema are made as you have re-iterated above.
Do you have any rough idea of when such a feature may be available to use?
Thanks again,
Justin
from graphql-java-codegen.
@JustinBlandford
Thanks for your feedback. I am glad that you found this helpful.
I am targeting to release this feature by the end of this week.
from graphql-java-codegen.
@kobylynskyi that's great, thanks
from graphql-java-codegen.
@JustinBlandford
This feature is available in plugin version 1.6.0.
- Sample plugin configuration: https://github.com/kobylynskyi/graphql-java-codegen/blob/master/plugins/maven/example-client/pom.xml
- Sample GraphQL request using generated classes: https://github.com/kobylynskyi/graphql-java-codegen/blob/master/plugins/maven/example-client/src/main/java/io/github/kobylynskyi/order/external/ProductServiceGraphQLClient.java#L37
Please feel free to open an issue in this project or feature request if you have any suggestions/ideas.
Thanks!
from graphql-java-codegen.
Related Issues (20)
- "...on" is skipped in all$ methods for union and interface projections HOT 2
- parameterized @external field resolver should not generate resolver methods HOT 2
- sanitizeValues() tries to mutate the input settings data HOT 2
- ?toString gives double double quotes on Strings, and no way to get unquoted string
- allow creating setter definitions in interfaces HOT 1
- chained setters HOT 6
- provide Lombok compatibility HOT 1
- How do I generate a Java object and pass parameters like a directive? Can you give me an example?
- Unable to serialize Object
- allow providing additional custom imports
- Add an ability to generate DataFetcherResult for a specific fields in Java HOT 4
- Custom type mapping for enum not generating correctly when default enum value is specified HOT 1
- parameterized @external field resolver should not generate resolver methods
- When generating java pojo, the attribute type of the pojo class becomes boolean
- CLI API
- initializeNullableTypes is not applied for parameterized inputs HOT 1
- Gradle cache doesn't work when the same project is cloned to different location and graphqlCodegen task is executed HOT 1
- Generating POJO from introspection result not working HOT 1
- Support Custom Type Configuration
- Working wildcard usage within "graphqlSchemaPaths"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-java-codegen.