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

nullable openapi properties converted to non-nullable gql fields #359

Description

@nlundquist

OpenAPI properties may be nullable & required. required only indicates that a key must be present in an object to be valid, it makes no restriction on the type of the value corresponding to that key. openapi-to-graphql assumes that required OpenAPI properties are non-nullable:

const requiredProperty =
typeof def.required === 'object' && def.required.includes(fieldTypeKey)

To Reproduce
Use openapi-to-graphql on a spec with type with a required field that is also nullable. Queries for that type which return a null for that nullable field cause unexpected validation errors.

Expected behavior
No validation errors when returning nulls for explicitly nullable fields.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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