Skip to content

Weird Type From OpenAPI when Using AnyOf for Nullability #8719

@graham-iheart

Description

@graham-iheart

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

To Reproduce Steps to reproduce the behavior:

  • Include a property in a component schema that looks something like this:
{
  "anyOf": [
    {"type": "string"},
    {"type": "null"}
  ]
}
  • The following type gets generated:
type Property @join__type(graph: GRAPH)  {
  String: String @resolveRoot(subgraph: "Graph") 
  Void: Void @resolveRoot(subgraph: "Graph") 
}

Reproduction Codesandbox
Expected behavior

I would expect it to generate a nullable scalar type.

Environment:

  • OS: MacOS 15.6
  • "@graphql-hive/gateway": "^1.16.3",
  • "@graphql-mesh/compose-cli": "^1.4.12",
  • "@graphql-mesh/types": "^0.104.7",
  • "@graphql-mesh/utils": "^0.104.7",
  • "@omnigraph/openapi": "^0.109.14",
  • "graphql": "^16.11.0
  • NodeJS: 24.4.0

Additional context

I'm happy to send in a fix for this if you could just point me in the right direction in the codebase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions