Skip to content

bug: TypeError: Redefinition of reserved type 'String' - Graphql generate-return-types #713

Closed

Description

@BaptisteGi

Component

infrahubctl

Infrahub SDK version

1.0.17

Current Behavior

When running infrahubctl graphql generate-return-types queries I got the following exception: Error: Redefinition of reserved type 'String'

KeyError: '__typename'

During handling of the above exception, another exception occurred:
    raise TypeError(f"Redefinition of reserved type {name!r}")
TypeError: Redefinition of reserved type 'String'

Expected Behavior

I expect this command to work

Steps to Reproduce

  • Setup project
mkdir some-project
cd some-project
mkdir queries
uv init
uv add 'infrahub-sdk[all]'
export INFRAHUB_API_TOKEN=06438eb2-8019-4776-878c-0941b1f1d1ec
  • Add the following query1.gql in queries folder
query Test {
  BuiltinTag {
    edges {
      node {
        __typename
        name {
          value
        }
      }
    }
  }
}
  • Run command infrahubctl graphql export-schema
  • Then infrahubctl graphql generate-return-types queries

=> This will fail with error described above

  • Remove __typename from query
  • Then infrahubctl graphql generate-return-types queries

=> This works

Additional Information

The __typename field is not explicitly defined in the GraphQL schema. In GraphQL, __typename is an introspection meta-field that's automatically available on all types - it doesn't need to be (and shouldn't be) explicitly defined in the schema. The problem is that ariadne-codegen is trying to look up __typename in the schema's type map and failing because it's not there (it's a built-in introspection field). When it fails to find it, it tries to create a fallback GraphQLScalarType(name="String"), but this causes the "Redefinition of reserved type 'String'" error because String is a reserved built-in scalar type in GraphQL. This is a bug in ariadne-codegen, not in your query or schema.

Activity

  1. coderabbitai commented on Dec 29, 2025

    @coderabbitai

    📝 CodeRabbit Plan Mode

    Generate an implementation plan and prompts that you can use with your favorite coding agent.

    • Create Plan
    Examples

    🔗 Similar Issues

    Related Issues

    👤 Suggested Assignees

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  2. added a commit that references this issue on Dec 29, 2025
  3. linked a pull request that will close this issueFix issue #713 and #712 #714on Dec 29, 2025
  4. added a commit that references this issue on Dec 30, 2025
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

    type/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions