Code Monkey home page Code Monkey logo

Comments (14)

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

Oups, I released only for maven.
I'll do the gradle release ASAP.

I'll notify you here.

from graphql-maven-plugin-project.

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

Hum,

Can you give some more information on your system:

  • Are you using the client or the server part ? Or both ?
  • If not both, what system is at the other side ? And what date/time format does it expect ?
  • If you're using the client part of this plugin, can you set the log level to trace, and paste the request and response here ?

Etienne

from graphql-maven-plugin-project.

Austin-Russell avatar Austin-Russell commented on August 28, 2024

Hey Etienne, thank you for taking a look!

I'm using only the client side. The server side uses the following packages for it's graphql construction:
<groupId>com.graphql-java-kickstart</groupId>
<artifactId>graphql-spring-boot-starter</artifactId>

<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-extended-scalars</artifactId>

The date/time format that it is expecting is the java object OffsetDateTime.

I will work on getting together a trace.

from graphql-maven-plugin-project.

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

BTW,
There are different ways to format a date.

A way is that you copy the com.graphql_java_generator.customscalars.GraphQLScalarTypeDateTime into a class of you own, and you adapt it according to your needs.

But the best way is probably that you also use the com.graphql-java:graphql-java-extended-scalars GraphQL implementation also on client side. Just use the graphql.scalars.ExtendedScalars.DateTime custom scalar.
Doing this should insure an homogeneous formatting.

Etienne

from graphql-maven-plugin-project.

gjvoosten avatar gjvoosten commented on August 28, 2024

@etienne-sf I'm running into the same problem (although with the Gradle plugin v1.12.1, but the code is the same if I'm not mistaken). I do have a custom scalar registered, however it is not being called for parameters directly in a query (not as bind parameters/variables). This is from the logging (slightly edited for brevity):

TRACE com.graphql_java_generator.client.QueryExecutorImpl: Executing GraphQL request: {"query":"query{graph(endDate:2021-03-09T10:32:16.511492995Z,startDate:2021-03-07T10:32:16.511446977Z){obj{uuid … __typename} x y __typename}}","variables":null,"operationName":null}
WARN notprivacysafe.graphql.GraphQL: Query failed to parse : 'query{graph(endDate:2021-03-09T10:32:16.511492995Z,startDate:2021-03-07T10:32:16.511446977Z){obj{uuid … __typename} x y __typename}}'
WARN my.package.resources.GraphQlResource: Errors: [InvalidSyntaxError{ message=Invalid Syntax : Invalid syntax: token recognition error at: '-03' at line 1 column 25 ,offendingToken=null ,locations=[SourceLocation{line=1, column=25}] ,sourcePreview=query{graph(endDate:2021-03-09T10:32:16.511492995Z,startDate:2021-03-07T10:32:16.511446977Z){obj{uuid … __typename} x y __typename}}}]

As you can see, the request is sent as:

query{graph(endDate:2021-03-09T10:32:16.511492995Z,startDate:2021-03-07T10:32:16.511446977Z){obj{uuid … __typename} x y __typename}}

whereas it should have been sent e.g. properly quoted as:

query{graph(endDate:"2021-03-09T10:32:16.511492995Z",startDate:"2021-03-07T10:32:16.511446977Z"){obj{uuid … __typename} x y __typename}}

from graphql-maven-plugin-project.

gjvoosten avatar gjvoosten commented on August 28, 2024

Digging somewhat deeper it appears to be because the generated code in the QueryExecutor has:

			, InputParameter.newBindParameter("endDate","queryGraphEndDate", false, null)
			, InputParameter.newBindParameter("startDate","queryGraphStartDate", false, null)

If I change that (manually) by replacing null with my custom scalar instance:

			, InputParameter.newBindParameter("endDate","queryGraphEndDate", false, DateTimeMapper.GraphQLDateTime)
			, InputParameter.newBindParameter("startDate","queryGraphStartDate", false, DateTimeMapper.GraphQLDateTime)

it works correctly.
The question then becomes: how do I convince the generator to add the custom scalar instance here?

from graphql-maven-plugin-project.

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

You're right that the code is the same between the Maven and the Gradle versions.

When you say "_ I do have a custom scalar registered_", you mean that the Custom Scalar is registered in the build.gradle file, correct ?

The question then becomes: how do I convince the generator to add the custom scalar instance here?

This is an interesting way of asking the question
:)

And actually, the generator always write null, in this InputParameter.newBindParameter fifth parameter. Which is not really "convincing" for the generator.

I'll add a JUnit test, then a correction for this one.

Thanks for the detailed report.

Etienne

from graphql-maven-plugin-project.

gjvoosten avatar gjvoosten commented on August 28, 2024

When you say "_ I do have a custom scalar registered_", you mean that the Custom Scalar is registered in the build.gradle file, correct ?

Indeed. (It's actually for java.time.Instant as that better semantics than java.util.Date, but that's just a detail.)

This is an interesting way of asking the question

Polite as ever, me. 😉

Thanks for working on a fix! 👍

from graphql-maven-plugin-project.

gjvoosten avatar gjvoosten commented on August 28, 2024

[Side note: this appears to be related to #26 if I read things right.]

from graphql-maven-plugin-project.

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

Hello,

Can you check the 1.12.5 release ?

from graphql-maven-plugin-project.

gjvoosten avatar gjvoosten commented on August 28, 2024

Can you check the 1.12.5 release ?

@etienne-sf Is there a new release of the Gradle plugin? Else I need some assistance on how to use the Maven plugin in my Gradle project to test this.

from graphql-maven-plugin-project.

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

I just released the 1.12.5, for Gradle

from graphql-maven-plugin-project.

gjvoosten avatar gjvoosten commented on August 28, 2024

@etienne-sf Works like a charm, merci beaucoup!

from graphql-maven-plugin-project.

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

Thanks
:)

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.