solo-io / gloo

The Feature-rich, Kubernetes-native, Next-Generation API Gateway Built on Envoy
https://docs.solo.io/
Apache License 2.0
4.08k stars 437 forks source link

Unable to pass enums as args in GraphQL queries #7324

Open day0ops opened 1 year ago

day0ops commented 1 year ago

Gloo Edge Version

1.12.x (latest stable)

Kubernetes Version

1.22.x

Describe the bug

In OASv3, if the RESTful endpoint findByStatus takes an enum as a parameter findByStatus?status=available then the equivalent GraphQL spec looks like,

        findPetsByStatus(

          """Status values that need to be considered for filter"""
          status: [Status3ListItem]!
        ): [Pet] @resolve(name: "petstore-upstream_apps-configuration|Query|findPetsByStatus")

where the status is an enum.

      enum Status3ListItem {
        available
        pending
        sold
      }

However, when querying this with

query PetsQuery {
  findPetsByStatus(status: ["sold"]) {
    name
  }
}

it returns an error

{
  "errors": [
    {
      "message": "Expected Enum value name: Status3ListItem",
      "locations": [
        {
          "line": 2,
          "column": 29
        }
      ]
    },
    {
      "message": "Incompatible argument type: Query field: findPetsByStatus name: status",
      "locations": [
        {
          "line": 2,
          "column": 20
        }
      ]
    }
  ]
}

Steps to reproduce the bug

  1. Run the project artifacts graphql.zip
  2. Test with curl -iv http://<proxy endpoint>/graphql -H 'Content-Type: application/json' -d '{"query": "query PetsQuery {findPetsByStatus(status: [\"sold\"]) {name}}" }'

Expected Behavior

Performing a query which uses enum as an arg

Additional Context

Tested on Gloo Edge 1.12.30

Server: {"type":"Gateway","enterprise":true,"kubernetes":{"containers":[{"Tag":"latest","Name":"discovery-ee","Registry":"quay.io/solo-io"},{"Tag":"latest","Name":"gloo-ee-envoy-wrapper","Registry":"quay.io/solo-io"},{"Tag":"1.12.30","Name":"access-logger","Registry":"quay.io/solo-io"},{"Tag":"latest","Name":"gloo-ee","Registry":"quay.io/solo-io","OssTag":"1.12.30"},{"Tag":"latest","Name":"observability-ee","Registry":"quay.io/solo-io"},{"Tag":"latest","Name":"rate-limit-ee","Registry":"quay.io/solo-io"},{"Tag":"6.2.4","Name":"redis","Registry":"docker.io"}],"namespace":"gloo-system"}}
kdorosh commented 1 year ago

reopening until fix is merged into gloo control plane @saiskee ; envoy fix was merged

saiskee commented 1 year ago

is a backport needed on this?

ashpost commented 1 year ago

Its fixed in main... will be released in 1.13 beta release. Backport isn't needed for now.

github-actions[bot] commented 4 months ago

This issue has been marked as stale because of no activity in the last 180 days. It will be closed in the next 180 days unless it is tagged "no stalebot" or other activity occurs.