Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure cynic schemas in Cargo.toml #761

Open
obmarg opened this issue Aug 5, 2023 · 3 comments
Open

Configure cynic schemas in Cargo.toml #761

obmarg opened this issue Aug 5, 2023 · 3 comments
Labels
✨ enhancement New feature or request

Comments

@obmarg
Copy link
Owner

obmarg commented Aug 5, 2023

I'm not certain about this idea, but it could be nice for the names & locations of cynic schemas to be configured in the metadata section of the users Cargo.toml.

This would allow:

  • The build.rs to read from here
  • Potentially the derives could read from there (although tbh I'd rather they don't for speed purposes)
  • The CLI could read from there for introspection
  • If I integrate the generator into the CLI then it could also read from there
  • Any CI integrations (probably powered by the CLI) could also read from there.

My main reservation is adding extra dependencies (either cargo_metadata or the toml library) into the dep tree. But if we end up supporting all the above use cases it could be pretty nice.

@obmarg obmarg added the ✨ enhancement New feature or request label Aug 5, 2023
@obmarg
Copy link
Owner Author

obmarg commented Aug 5, 2023

An alternative to this might be to recommend a conventional place to put schemas, combined with a cynic specific config file. So:

- Cargo.toml
- schemas/
  - github.graphql
  - cynic-schemas.json

Or similar? Not sure

@obmarg
Copy link
Owner Author

obmarg commented Aug 5, 2023

Forgot I'd already documented this in #687 - but I prefer the description here so I'll close #687

@obmarg
Copy link
Owner Author

obmarg commented Jan 5, 2024

A sensible approach to this would be:

  • Add a cynic-cargo-toml 3rd party library.
  • This provides a function to call in build.rs that will:
    • Read schema paths out of Cargo.toml (or a separate file? not sure)
    • Register them as schemas (either with rkyv or not)
  • The derive mechanism continues to work as usual.
  • The CLI can be updated to allow easy introspection of the defined schemas as well.

A future extension could have the build.rs read URLs out of Cargo.toml and then introspect those, but I'm still skeptical that's a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant