Configuration
July 24, 2026 · View on GitHub
ariadne-codegen reads configuration from [tool.ariadne-codegen] section in your pyproject.toml. You can use other configuration file with --config option, eg. ariadne-codegen --config custom_file.toml
Minimal configuration for client generation:
[tool.ariadne-codegen]
schema_path = "schema.graphql"
queries_path = "queries.graphql"
Required settings:
queries_path- path to file/directory with queries (Can be optional ifenable_custom_operationsis used)
Exactly one of the following parameters is required - they are mutually exclusive, so only one schema source may be used at a time (see Schema sources):
schema_path- path to file/directory with graphql schemaschema_paths- list of local paths and/or installed-package sources to build the schema fromremote_schema_url- url to graphql server, where introspection query can be performed
Optional settings:
remote_schema_headers- extra headers that are passed along with introspection query, eg.{"Authorization" = "Bearer token"}. To include an environment variable in a header value, prefix the variable with$, eg.{"Authorization" = "$AUTH_TOKEN"}remote_schema_verify_ssl(defaults totrue) - a flag that specifies whether to verify ssl while introspecting remote schemaremote_schema_timeout(defaults to5) - timeout in seconds while introspecting remote schemaremote_schema_http_client_path- absolute import path to the HTTP client used to introspect remote schema. If not provided, defaulthttpxclient is used. See Remove schema client customization below for details.target_package_name(defaults to"graphql_client") - name of generated packagetarget_package_path(defaults to cwd) - path where to generate packageclient_name(defaults to"Client") - name of generated client classclient_file_name(defaults to"client") - name of file with generated client classbase_client_name(defaults to"AsyncBaseClient") - name of base client class. See Base Client customization below for details.base_client_file_path(defaults to.../ariadne_codegen/client_generators/dependencies/async_base_client.py) - path to file wherebase_client_nameis definedbase_client_module_name(defaults to the file name ofbase_client_file_path) - name of the module the base client is copied to and imported from in the generated packageenums_module_name(defaults to"enums") - name of file with generated enums modelsinput_types_module_name(defaults to"input_types") - name of file with generated input types modelsfragments_module_name(defaults to"fragments") - name of file with generated fragments modelsinclude_comments(defaults to"stable") - option which sets content of comments included at the top of every generated file. Valid choices are:"none"(no comments),"timestamp"(comment with generation timestamp),"stable"(comment contains a message that this is a generated file)convert_to_snake_case(defaults totrue) - a flag that specifies whether to convert fields and arguments names to snake caseinclude_all_inputs(defaults totrue) - a flag specifying whether to include all inputs defined in the schema, or only those used in supplied operationsinclude_all_enums(defaults totrue) - a flag specifying whether to include all enums defined in the schema, or only those used in supplied operationsasync_client(defaults totrue) - default generated client isasync, change this to optionfalseto generate synchronous client insteadopentelemetry_client(defaults tofalse) - default base clients don't support any performance tracing. Change this option totrueto use the base client with Open Telemetry support.multipart_uploads(defaults totrue) - when set tofalse, a lighter base client variant is generated that omits multipart file upload support.files_to_include(defaults to[]) - list of files which will be copied into generated packageplugins(defaults to[]) - list of plugins to use during generationenable_custom_operations(defaults tofalse) - enables building custom operations. Generates additional files that contains all the classes and methods for generation. Addsgraphql-coreto the generated package's runtime dependencies.defer_model_build(defaults tofalse) - defers building of generated Pydantic models until they are first used. Setsdefer_build=Trueon the generatedBaseModeland skips the eagermodel_rebuild()calls, so importing the generated package is much faster for large schemas. See Improving import performance.use_alias_generator(defaults tofalse) - setsalias_generator=to_camelon the generatedBaseModel, so fields no longer need their ownField(alias=...)when the alias can be derived from the Python name. Requirespydantic >= 2.8. See Improving import performance.lazy_imports(defaults tofalse) - generates an__init__.pythat imports each module the first time a name from it is used, instead of importing all of them up front, so an application only pays for the models it touches. Also enables theClientForwardRefsPlugin, which is needed for the deferral to hold: it keepsclient.pyfrom importing the input types it only names in annotations. See Improving import performance.include_typename(defaults totrue) - a flag that specifies whether to include the__typenamefield in generated modelsignore_extra_fields(defaults totrue) - whentrue, generated models ignore extra fields returned by the server; set tofalseto addextra="forbid"to the base model so unexpected fields raise a validation errordefault_optional_fields_to_none(defaults tofalse) - whentrue, optional fields in generated models default toNoneinstead of being required keyword argumentsskip_validation_rules(defaults to["NoUnusedFragments"]) - list of graphql-core validation rule names to skip when validating operations against the schema
Scalars
Custom scalar mappings are configured in per-scalar subsections rather than a single key:
[tool.ariadne-codegen.scalars.{graphql scalar name}]
type = "..."
See Custom scalars for the full syntax.
Introspection query settings:
These options control which fields are included in the GraphQL introspection query when using remote_schema_url. See Schema sources for more details.
introspection_descriptions(defaults tofalse) – include descriptions in the introspection resultintrospection_input_value_deprecation(defaults tofalse) – include deprecation information for input valuesintrospection_specified_by_url(defaults tofalse) – includespecifiedByUrlfor custom scalarsintrospection_schema_description(defaults tofalse) – include schema descriptionintrospection_directive_is_repeatable(defaults tofalse) – includeisRepeatableinformation for directivesintrospection_input_object_one_of(defaults tofalse) – includeoneOfinformation for input objects
Remote schema client customization
By default, httpx is used to introspect a remote schema. Another client can be used instead by setting remote_schema_http_client_path. The provided client must implement the following protocol:
class Response(Protocol):
status_code: int
def json(self, **kwargs: Any) -> Any: ...
class HttpClient(Protocol):
def post(
self,
url: Any | str,
json: Any | None = None,
headers: Any | None = None,
verify: Any | None = None,
timeout: Any | None = None,
**kwargs: Any,
) -> Response: ...
If the provided import path points to a module, the module itself must implement the protocol. If the provided import path points to a callable, it is called with a single argument: config_dict: dict (the parsed pyproject.toml), and the returned object is expected to implement HttpClient protocol.
Base Client customization
The base_client_file_path and base_client_name can be used to provide a custom base client implementation. It should implement the following protocol for async client:
class AsyncBaseClient(Protocol):
async def execute(
self,
query: str,
operation_name: Optional[str] = None,
variables: Optional[dict[str, Any]] = None,
**kwargs: Any,
) -> Response: ...
def get_data(self, response: Response) -> dict[str, Any]: ...
Protocol for sync client:
class BaseClient(Protocol):
def execute(
self,
query: str,
operation_name: Optional[str] = None,
variables: Optional[dict[str, Any]] = None,
**kwargs: Any,
) -> Response: ...
def get_data(self, response: Response) -> dict[str, Any]: ...
Related guides
Several settings have dedicated guides that explain them in context:
- Schema sources -
schema_path,remote_schema_url,remote_schema_*, andintrospection_* - Schema generation -
graphqlschemamode and its settings - File uploads -
multipart_uploads - Custom scalars - scalar sections and
files_to_include - Async vs sync client -
async_client - Open Telemetry -
opentelemetry_client - Plugins -
plugins - Custom operation builder -
enable_custom_operations