-
-
Notifications
You must be signed in to change notification settings - Fork 536
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
Implement codegen for queries #1655
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1655 +/- ##
==========================================
+ Coverage 98.19% 98.34% +0.14%
==========================================
Files 130 139 +9
Lines 4596 5185 +589
Branches 794 936 +142
==========================================
+ Hits 4513 5099 +586
Misses 44 44
- Partials 39 42 +3 |
d90b059
to
7604141
Compare
might be worth using this for tests: https://github.com/joseph-roitman/pytest-snapshot |
fcbc9c3
to
a62454a
Compare
158d2fd
to
dc6626d
Compare
Thanks for adding the Here's a preview of the changelog: This release adds an experimental codegen feature for queries. You can use the following command: strawberry codegen --schema schema --output-dir ./output -p python query.graphql to generate python types that correspond to your GraphQL query. Here's the preview release card for twitter: Here's the tweet text:
|
0654acf
to
d57f965
Compare
Hi 👋 You can find a preview of the docs here: https://strawberry.rocks/docs/pr/1655/README |
f9c20f8
to
2c1deae
Compare
/pre-release |
Pre-release👋 Pre-release 0.103.0.dev.1647276413 [8ca8d37] has been released on PyPi! 🚀 poetry add strawberry-graphql==0.103.0.dev.1647276413 |
/pre-release |
2c5ec70
to
cf4cbc1
Compare
/pre-release |
21bf685
to
7d39e1f
Compare
7d39e1f
to
c6cf2a7
Compare
* Implement codegen for queries * Add support for imports * Move python codegen to a plugin * Better print handling * Wip * WIP * Implement initial typescript plugin * Some type fixes * Fix codegen * Implement cli * fix enum * Fix tests * Move tests to snapshot * Update types * Add some error handling * wip * Initial implementation of allowing to generate code from operation * Directives * More scalars * Move plugin from test to core * Add initial support for specifing plugins from CLI * Initial support for variables * Improve support for variables * Collect nested input types * Refactor fix types * Initial support for returning multiple files * Support multiple files per plugin * Update command * Test CLI * Increase test coverage * Add imports for scalars * Write to files * Add some output * Add release notes * Add docs and update cli interface * Fix issue with mypy cache * Fix type * Add support for list values * Add support for enum values * Use pathlib for better writing * wip cli plugin * Improve CLI plugin * Store types for operation and variables * Update types * Update docs * Allow to override console plugin * Fix type * Update command
Description
This is WIP 😊 This PR implements a feature similar to GraphQL codegen that allows to transform a GraphQL query into code, at the moment I'll be targeting only Python[1] code, but this can be expanded to other languages too (maybe via installable plugins).
[1] The python codegen will be a plugin. We'll be providing a generic interface that will make use of plugins to generate code.
Note: the code is kinda recreating
GraphQLType
,GraphQLScalar
and so on. They are meant as tiny datastructures that will be used to generate code :)TODO:
There are some todo left in the code, on top of that we need:
In other PRs:
pip install strawberry-graphql[cli]
|, list
) could be enabled based on the version/cc @peniqliotuv
Types of Changes