-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Description
After ariadne-codegen generation enums are not imported in custom_queries.py.
Prerequisites
Python version: 3.12
ariadne-codegen version affected: 0.17.0+ (to be more precise, starting from commit (drop python 3.9 and support python 3.14 (https://github.com/mirumee/ariadne-codegen/pull/398)))
Consider the following GraphQL schema:
enum SortDirection {
ascending
descending
}
enum ProduceType {
fruit
vegetable
}
type Produce {
id: ID!
name: String!
produceType: ProduceType!
}
type Query {
produce(id: ID!): Produce
allProduces(sortDirection: SortDirection!): [Produce!]!
}
and the following schema.toml:
[tool.ariadne-codegen]
schema_path = "schema.graphql"
target_package_name = "schema"
enable_custom_operations = true
async_client = true
Code Generation
I generated code with ariadne-codegen --config schema.toml.
Expected Behaviour
No ImportError in custom_queries.py.
Actual Behaviour
The file custom_queries.py has no enum imports, which causes ImportError.
custom_queries.py contents:
# Generated by ariadne-codegen
from typing import Any
from .custom_fields import ProduceFields
class Query:
@classmethod
def produce(cls, id: str) -> ProduceFields:
arguments: dict[str, dict[str, Any]] = {"id": {"type": "ID!", "value": id}}
cleared_arguments = {
key: value for key, value in arguments.items() if value["value"] is not None
}
return ProduceFields(field_name="produce", arguments=cleared_arguments)
@classmethod
def all_produces(cls, sort_direction: SortDirection) -> ProduceFields:
arguments: dict[str, dict[str, Any]] = {
"sortDirection": {"type": "SortDirection!", "value": sort_direction}
}
cleared_arguments = {
key: value for key, value in arguments.items() if value["value"] is not None
}
return ProduceFields(field_name="allProduces", arguments=cleared_arguments)
Problem
I guess the problem is in this diff.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels