Skip to content

Enum List as input #115

@alexcibotari

Description

@alexcibotari

Hello,

I have next GraphQL definition:

Query {
countries(regions: [Region!]): [Country!]
}

enum Region {
  EUROPE
  ASIA
}

type Country {
  code: String!
  name: String!
  regions: [Region!]
}

and Java
public Set<Country> getCountries(Set<RoamingRegion> regions)
or
public Set<Country> getCountries(Optional<Set<RoamingRegion>> regions)

when I do a request to GraphQL-Java i receive an error

{
  "data": null,
  "errors": [
    {
      "message": "Validation error of type VariableTypeMismatch: Variable type doesn't match",
      "locations": [
        {
          "line": 2,
          "column": 43
        }
      ],
      "description": "Variable type doesn't match",
      "validationErrorType": "VariableTypeMismatch",
      "errorType": "ValidationError",
      "path": null,
      "extensions": null
    }
  ]
}

UPDATE :

query getCountries($regions: [Region]!) {
  countries(regions: $regions){
    code
    name
    regions
  }
}

as variables I send list of Regions as String because TypeScript automatically convert Array of Enums in to Array of Strings

['EUROPE','ASIA']

if I try the same but instead of List of Regions I use Single enum as input, everything works :(
This why I think problem is in List of Enums

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions