Code Monkey home page Code Monkey logo

Comments (5)

etienne-sf avatar etienne-sf commented on August 28, 2024

Please not that you should avoid DirectQueries for complex queries. And actually, DirectQueries don't manage field parameters as input types.

In the last commit, I added a specific error message, to precise that.

Consider preparing queries, with parameter as bind variables.

Etienne

from graphql-maven-plugin-project.

abedeoan avatar abedeoan commented on August 28, 2024

Hi Etienne,

Thank you for picking up this item that I reported by e-mail.

I am adding below a dummy query response - for the thread's completeness.

private static final String PJ_QUERY_RESPONSE_DEF = "{" +
" id" +
" time " +
" machine {" +
" id" +
" name" +
" }" +
" jobs { " +
" data " +
"(filter: {" +
" domain: "Mining"" +
" })" +
"{" +
" serviceId" +
" subData {" +
" indicator" +
" id" +
" }" +
" }" +
" }" +
" }";

How should the bind parameters map look like in this situation?
I tried using a prepared query and binding either domain or filter, but the same error message occurs; so maybe I am misusing the API?
Any help would be appreciated.

from graphql-maven-plugin-project.

etienne-sf avatar etienne-sf commented on August 28, 2024

I reformated your String for better readabilty:
"{id time machine {id name} jobs {data(filter: {domain: "Mining"}){serviceId subData {indicator id}}}}"

The issue here is that the plugin can't currently read the {domain: "Mining"} json part.

So you have to replace the query response by this one:
"{id time machine {id name} jobs {data(filter: ?filterParam){serviceId subData {indicator id}}}}"

This means that there is a Bind Variable of name "filterParam" that must be provided at runtime.
You don't have to provide the map at runtime : the client method allows you to add parameters at the end. The method will create the Map on its own.
These parameters must be couples of values :

  • The parameter name (here: "filterParam")
  • The parameter value (Here: an object with a "domain" field, whose value is "Mining")

You can see samples in the Forum client project, in the com.graphql_java_generator.samples.forum.client.graphql.PreparedQueries

from graphql-maven-plugin-project.

abedeoan avatar abedeoan commented on August 28, 2024

Hi Etienne,

Thank you for the provided example! It answered my questions!

I consider this Issue Resolved.

Regards,
Amelia

from graphql-maven-plugin-project.

etienne-sf avatar etienne-sf commented on August 28, 2024

This issue is solved in version 1.2

from graphql-maven-plugin-project.

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.