Skip to content

GraphQL parser does not handle multiple input schemas like other tools #2872

@siminn-arnorgj

Description

@siminn-arnorgj

Describe the bug

Currently when providing the GraphQL parser with either multiple schemas or a directory containing multiple schemas, each schema is parsed in isolation, this is not the common behavior of GraphQL tools. Normally when multiple schemas are provided they are merged together before parsing, allowing cross references between types defined in different files. I believe this is the expected behavior here as well.

To Reproduce

We have a directory called schemas/

apples.graphql:

type Apple {
  color: String!
}

applesplus.graphql:

extend type Apple {
  taste: String!
}

Used commandline:

$ datamodel-codegen --input ./schemas --input-file-type graphql --output ./output

Current behavior

TypeError: Cannot extend type 'Apple' because it is not defined.

Expected behavior

We expect a single Apple model to be generated with both color and taste fields.

Version:

  • OS: MacOS 26.2
  • Python version: 3.13.9
  • datamodel-code-generator version: 507c33f

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