skip to Main Content

We are using the Shopify Admin API in GraphQL to create an App. We are developing based on this example here – https://github.com/graphql-java-generator/GraphQL-Forum-Maven-Tutorial-client

We downloaded the schema from Shopify using the apollo (nodejs) and the POJO files were generated automatically. We were able to request the Shopify Storefront APIs successfully, but the Admin APIs have got an extra field "extensions" which makes the deserialisation to fail.

Response in Insomnia:

The error we are receiving:

Exception in thread "main" javax.ws.rs.client.ResponseProcessingException: 

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "extensions" (class com.graphql_java_generator.client.response.JsonResponseWrapper), not marked as ignorable (2 known properties: "data", "errors"])
 at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 387] (through reference chain: com.graphql_java_generator.client.response.JsonResponseWrapper["extensions"])
    at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:702)
    at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$1(JerseyInvocation.java:632)
    at org.glassfish.jersey.client.JerseyInvocation.call(JerseyInvocation.java:654)
    at org.glassfish.jersey.client.JerseyInvocation.lambda$runInScope$3(JerseyInvocation.java:648)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:205)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:390)
    at org.glassfish.jersey.client.JerseyInvocation.runInScope(JerseyInvocation.java:648)
    at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:631)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:434)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:335)
    at com.graphql_java_generator.client.QueryExecutorImpl.execute(QueryExecutorImpl.java:142)
    at org.forum.client.util.QueryRootExecutor.shop(QueryRootExecutor.java:20303)
    at org.graphql_forum_sample.client.GraphQLClient.execPartialRequests(GraphQLClient.java:95)
    at org.graphql_forum_sample.client.Main.main(Main.java:19)
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "extensions" (class com.graphql_java_generator.client.response.JsonResponseWrapper), not marked as ignorable (2 known properties: "data", "errors"])
 at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 387] (through reference chain: com.graphql_java_generator.client.response.JsonResponseWrapper["extensions"])
    at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:61)
    at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:855)
    at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1212)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1604)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1582)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:299)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:156)
    at com.fasterxml.jackson.databind.ObjectReader._bind(ObjectReader.java:2042)
    at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1201)
    at org.glassfish.jersey.jackson.internal.jackson.jaxrs.base.ProviderBase.readFrom(ProviderBase.java:837)
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:233)
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:212)
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:132)
    at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1072)
    at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:885)
    at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:819)
    at org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:298)
    at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:699)

I have tried adding the @JsonIgnoreProperties(ignoreUnknown = true) to POJOs and also added the deserialization feature to object mapper:

ObjectMapper o = new ObjectMapper();
o.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
o.disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
o.disable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE);
o.disable(DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES);
o.disable(DeserializationFeature.FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY);
o.disable(DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS);

Any help on how to include or ignore the extensions in the deserialization? Thanks!

2

Answers


  1. Chosen as BEST ANSWER

    This issue was solved with the latest release of the graphql-java-generator (1.12.3 and above). Thanks to the developers, they also included the extensions node in the code and released it.


  2. If you have not tried this, Consider it.

    o.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search