-
Notifications
You must be signed in to change notification settings - Fork 6
Description
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.gqlinqueriesfolder
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
__typenamefrom 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.