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

Custom root level queries and mutations via inheritance #77

Merged
merged 3 commits into from
Jul 11, 2024

Conversation

ninabernick
Copy link
Collaborator

@ninabernick ninabernick commented Jul 11, 2024

Add custom root level queries and mutations by inheriting the codegenned Query and Mutation classes. Also supports overriding codegenned resolvers. Adds docs on custom code.

@ninabernick ninabernick requested review from jgadling and j-x-han July 11, 2024 17:23
@jgadling
Copy link
Contributor

This is perfect, and so simple! 😍

Just two things:

  • I don't think we need to rename the base Query / Mutation classes to BaseQuery / BaseMutation - if someone wants to override them, they can come up with different class names
  • Can you write this up into a HOWTO style document (maybe as a markdown file in a docs dir?) so we have examples of how to extend platformics in various ways?

@ninabernick ninabernick changed the title [DO NOT MERGE] example of inheriting base queries and mutations Custom root level queries and mutations via inheritance Jul 11, 2024
## Adding root-level queries and mutations
Platformics will generate basic read and aggregate queries in `api/queries.py`. These are inherited by a query class in `custom_queries.py`, which will gain access to all the codegenned queries as well as allow you to implement your own queries. To add a new root level field (query), add the field to the query class in `custom_queries.py`:

```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you can do ```python for python syntax highlighting!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh!

Copy link
Collaborator

@j-x-han j-x-han left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎉

@ninabernick ninabernick merged commit a5ed8ba into main Jul 11, 2024
3 checks passed
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.

SPIKE: Can users edit files and still re-run codegen when their schemas change?
3 participants