Skip to content

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

Open
@nlundquist

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.

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