Skip to content
This repository was archived by the owner on Aug 2, 2023. It is now read-only.
This repository was archived by the owner on Aug 2, 2023. It is now read-only.

Problem Deserializing an Empty List #116

@trizzle21

Description

@trizzle21

Hello! I'm having a small issue with a graphQL request that returns an empty list. I'm currently querying the Shopify Bulk Ingestion with a request payload that looks like:

query { 
     bulkOperationRunQuery (query:"long query") {
        userErrors { 
              field 
              message 
        } bulkOperation { 
              id 
             status 
        } 
    } 
} 

which has a response that looks like

{
  "data": {
    "bulkOperationRunQuery": {
      "bulkOperation": {
        "id": "gid:\/\/shopify\/BulkOperation\/720918",
        "status": "CREATED"
      },
      "userErrors": []
    }
  }
}

I have my objects that look like

public class BulkIngestionQueryOperation {

    @GraphQLArgument(name="query", type="String")
    private BulkOperationRunQuery bulkOperationRunQuery;

    public BulkOperationRunQuery getBulkOperationRunQuery() {
        return bulkOperationRunQuery;
    }

    public void setBulkOperationRunQuery(BulkOperationRunQuery bulkOperationRunQuery) {
        this.bulkOperationRunQuery = bulkOperationRunQuery;
    }
}

@GraphQLProperty(name="bulkOperationRunQuery", arguments={
        @GraphQLArgument(name="query")
})
public class BulkOperationRunQuery {
    private BulkOperation bulkOperation;
    private UserErrors userErrors;

    public BulkOperation getBulkOperation() {
        return bulkOperation;
    }

    public void setBulkOperation(BulkOperation bulkOperation) {
        this.bulkOperation = bulkOperation;
    }

    public UserErrors getUserErrors() {
        return userErrors;
    }

    public void setUserErrors(UserErrors userErrors) {
        this.userErrors = userErrors;
    }
}

public class UserErrors {
    private String message;
    private String field;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getField() {
        return field;
    }

    public void setField(String field) {
        this.field = field;
    }

    public String toString() {
        return "error on " + field + " due to " + message;
    }
}

When I screw up the user fields and I get a UserError, my request deserializes correctly. However, when the request is successful, I get an empty list of UserErros to which I get the error,

'Cannot deserialize instance of `com.attentivemobile.bulk.ingestion.processor.model.graphql.UserErrors` out of START_ARRAY token
 at [Source: (String)"{"bulkOperationRunQuery":{"userErrors":[],"bulkOperation":{"id":"gid://shopify/BulkOperation/xxxxxxxxxxx","status":"CREATED"}}}"; line: 1, column: 40] 

Is there a feature or trick with that I'm not aware of or is this a known issue?

I know there are similar issues here, but they have a very different schema, doesn't involve an empty list and the solution involves moving the arguments to the nested object which is already the case here.

Thanks so much in advance!!

Tyler

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions