Skip to content

feat: add schema_paths for loading schema from local paths and installed packages AR-3#439

Merged
Minister944 merged 7 commits into
mainfrom
AR-3-local-schema-external-package-resolution
Jul 8, 2026
Merged

feat: add schema_paths for loading schema from local paths and installed packages AR-3#439
Minister944 merged 7 commits into
mainfrom
AR-3-local-schema-external-package-resolution

Conversation

@Minister944

@Minister944 Minister944 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Introduce a new schema_paths setting that builds the GraphQL schema from
multiple sources. Each entry is resolved either as a dotted Python attribute
path (e.g. pkg.SCHEMA_DIR or pkg.get_schema_files) - useful for pulling
type definitions from installed packages - or as a local file/directory path.

  • schema.py: add resolve_schema_paths and get_graphql_schema_from_paths
  • main.py: wire schema_paths into both client and graphqlschema strategies
  • settings.py: add the schema_paths field and make the three schema sources
    (schema_path, schema_paths, remote_schema_url) mutually exclusive -
    providing more than one now raises InvalidConfiguration; simplify
    using_remote_schema accordingly
  • docs/README: document schema_paths and the mutual-exclusivity rule

CI/CD does not pass. This is an unrelated error that is being fixed as part of AR-6

Acknowledgements

While working on this, we noticed #431 by @esfomeado, which also tackled
loading the schema from more than one source. After discussing it as a team,
we went with a different approach - a dedicated schema_paths setting that
additionally resolves dotted Python attribute paths from installed packages -
which we felt fit the project better. Thanks @esfomeado for raising the problem
and for your contribution! 🙏

Co-authored-by: esfomeado 1906254+esfomeado@users.noreply.github.com

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bce7c3e4-ba4f-41bb-8cad-f87045974465

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch AR-3-local-schema-external-package-resolution

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread ariadne_codegen/schema.py Outdated
Comment thread ariadne_codegen/settings.py Outdated
Comment thread docs/02-configuration.md Outdated
Comment thread ariadne_codegen/schema.py Outdated
Comment thread ariadne_codegen/schema.py Outdated
Comment thread ariadne_codegen/schema.py
Comment thread ariadne_codegen/schema.py
Comment thread ariadne_codegen/schema.py Outdated
…led packages

Introduce a new `schema_paths` setting that builds the GraphQL schema from
multiple sources. Each entry is resolved either as a dotted Python attribute
path (e.g. `pkg.SCHEMA_DIR` or `pkg.get_schema_files`) — useful for pulling
type definitions from installed packages — or as a local file/directory path.

- schema.py: add `resolve_schema_paths` and `get_graphql_schema_from_paths`
- main.py: wire `schema_paths` into both `client` and `graphqlschema` strategies
- settings.py: add the `schema_paths` field and make the three schema sources
  (`schema_path`, `schema_paths`, `remote_schema_url`) mutually exclusive —
  providing more than one now raises InvalidConfiguration; simplify
  `using_remote_schema` accordingly
- docs/README: document `schema_paths` and the mutual-exclusivity rule
@Minister944 Minister944 force-pushed the AR-3-local-schema-external-package-resolution branch from cee0b53 to 79de200 Compare July 1, 2026 17:11
Comment thread docs/02-configuration.md Outdated
Comment thread docs/02-configuration.md Outdated
Comment thread tests/test_schema.py Outdated
Comment thread tests/test_schema.py Outdated
Comment thread tests/test_schema.py Outdated
Comment thread tests/test_schema.py Outdated
Comment thread tests/test_schema.py Outdated
Comment thread tests/test_schema.py
Comment thread ariadne_codegen/schema.py
- schema.py: get_graphql_schema_from_path now delegates to
  get_graphql_schema_from_paths([schema_path]) so both entry points share one
  resolve -> read -> build flow (schema_path existence is already validated in
  BaseSettings.__post_init__, so the import-resolution branch is never reached)
- docs / README: describe schema_paths entries with "must be one of ..." and
  drop the redundant note about unresolvable import paths raising an error
- tests: consolidate local file+dir cases into one, merge the dotted-name
  file/dir cases, place the variable->file test next to variable->directory,
  group all "raises InvalidConfiguration" cases into one block, and drop the
  redundant existing-file-skips-importlib test
Comment thread tests/test_schema.py
@Minister944 Minister944 merged commit d94a9a5 into main Jul 8, 2026
6 checks passed
@Minister944 Minister944 deleted the AR-3-local-schema-external-package-resolution branch July 8, 2026 16:24
amin-farjadi pushed a commit to amin-farjadi/ariadne-codegen that referenced this pull request Jul 10, 2026
* origin/main:
  feat: Allow to use custom client for fetching remote schema [AR-2] (mirumee#444)
  feat: add schema_paths for loading schema from local paths and installed packages AR-3 (mirumee#439)
  feat: Allow to use non-httpx HTTP clients in default clients [AR-1] (mirumee#440)
  remove: unnecessary lines
  fix
  fix: tests
  fix: use explicit UTF-8 encoding for ruff format subprocess (mirumee#422) (mirumee#428)
  fix: wrap long lines to satisfy ruff E501
  docs: document multipart_uploads setting in README and configuration guide
  feat: add multipart_uploads setting to disable file upload support

# Conflicts:
#	ariadne_codegen/client_generators/package.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants