Coder Social home page Coder Social logo

Comments (8)

joffrey-bion avatar joffrey-bion commented on June 2, 2024 1

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:

  1. Define the projection of the response object (which fields to fetch)
  2. 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.

joffrey-bion avatar joffrey-bion commented on June 2, 2024

from graphql-java-codegen.

kobylynskyi avatar kobylynskyi commented on June 2, 2024

@joffrey-bion
I was not able to find a solution for client-side code generation in Java.

The idea of this feature would be:

  1. Define the projection of the response object (which fields to fetch)
  2. 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.

kobylynskyi avatar kobylynskyi commented on June 2, 2024

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.

JustinBlandford avatar JustinBlandford commented on June 2, 2024

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.

kobylynskyi avatar kobylynskyi commented on June 2, 2024

@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.

JustinBlandford avatar JustinBlandford commented on June 2, 2024

@kobylynskyi that's great, thanks

from graphql-java-codegen.

kobylynskyi avatar kobylynskyi commented on June 2, 2024

@JustinBlandford
This feature is available in plugin version 1.6.0.

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.