ardatan / graphql-mesh

🕸️ GraphQL Mesh - The Graph of Everything - Federated architecture for any API service

Home Page:https://the-guild.dev/graphql/mesh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`@omnigraph/openapi`: OpenAPI array values not converted correctly into GraphQL

dennisameling opened this issue · comments

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

Make sure to fork this template and run yarn generate in the terminal.

Please make sure Mesh package versions under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

When converting a OpenAPI spec to GraphQL, the array values may be empty in the GraphQL spec. Here's an example from my repo: https://github.com/dennisameling/omnigraph-openapi-array-bug

type Query {
  """Multiple status values can be provided with comma separated strings"""
  findPetsByStatus(status: queryInput_findPetsByStatus_status = available): [Pet]

  """
  Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
  """
  findPetsByTags(
    """Tags to filter by"""
    tags: [String]
  ): [Pet]
}

I'd expect [Pet] to be [Pet!] (note that I explicitly mean [Pet!] and not [Pet]!). When an array is provided, all of its values will be of the expected type. AFAIK, this is always how OpenAPI behaves (e.g. when converting an OpenAPI spec to TypeScript), but please correct me if I'm wrong.

To Reproduce Steps to reproduce the behavior:

GitHub repo: https://github.com/dennisameling/omnigraph-openapi-array-bug

git clone https://github.com/dennisameling/omnigraph-openapi-array-bug
cd omnigraph-openapi-array-bug
npm install
node index.js

The return array type of queries like findPetsByStatus and findPetsByTags is [Pet] instead of [Pet!].

Expected behavior

I expect the return type [Pet] to be [Pet!] instead.

Environment:

  • OS: macOS 14..3.1
  • @graphql-mesh/...: N/A (using @omnigraph/openapi 0.99.0)
  • NodeJS: v18.19.0

Additional context