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
Add support for printing dictionaries when using custom scalars #2048
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2048 +/- ##
==========================================
+ Coverage 98.03% 98.05% +0.02%
==========================================
Files 145 147 +2
Lines 5797 5874 +77
Branches 1080 1107 +27
==========================================
+ Hits 5683 5760 +77
Misses 58 58
Partials 56 56 |
Thanks for adding the Here's a preview of the changelog: This release adds support for printing default values for scalars like JSON. For example the following: import strawberry
from strawberry.scalars import JSON
@strawberry.input
class MyInput:
j: JSON = strawberry.field(default_factory=dict)
j2: JSON = strawberry.field(default_factory=lambda: {"hello": "world"}) will print the following schema: input MyInput {
j: JSON! = {}
j2: JSON! = {hello: "world"}
} Here's the tweet text:
|
0f5d04d
to
abf6fc0
Compare
abf6fc0
to
259bf0c
Compare
cba78b5
to
3de9f1d
Compare
for more information, see https://pre-commit.ci
@BryceBeagle I'll merge this since I need it for the federation 2.0 fixes (#2047) I'll open an issue about rewriting the printer 😊 |
* Bump ddtrace from 1.2.3 to 1.3.0 (strawberry-graphql#2050) Bumps [ddtrace](https://github.com/DataDog/dd-trace-py) from 1.2.3 to 1.3.0. - [Release notes](https://github.com/DataDog/dd-trace-py/releases) - [Changelog](https://github.com/DataDog/dd-trace-py/blob/1.x/CHANGELOG.md) - [Commits](DataDog/dd-trace-py@v1.2.3...v1.3.0) --- updated-dependencies: - dependency-name: ddtrace dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump types-setuptools from 63.2.1 to 63.2.2 (strawberry-graphql#2049) Bumps [types-setuptools](https://github.com/python/typeshed) from 63.2.1 to 63.2.2. - [Release notes](https://github.com/python/typeshed/releases) - [Commits](https://github.com/python/typeshed/commits) --- updated-dependencies: - dependency-name: types-setuptools dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add support for printing dictionaries when using custom scalars (strawberry-graphql#2048) * Add support for printing dictionaries when using custom scalars * Add support for nested dicts * Add support for arguments * Add test for bool and float * Add test for id * Test for list with values * Add comment back * Fix variable * More tests * More tests for lists * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add support for objects as default values * Test more cases * Ignore code paths * Add one more test for floats Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Release 🍓 0.122.0 * Remove autoreload test (strawberry-graphql#2053) * Fix aiohttp query operation selection (strawberry-graphql#2055) * Release 🍓 0.122.1 Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Patrick Arminio <patrick.arminio@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Botberry <bot@strawberry.rocks> Co-authored-by: Jonathan Ehwald <github@ehwald.info>
* Update dependencies Add Channels optional dependency and an Extra package for channels * Add documentation for Channels integration * Add implementation for basic Channels integration Complete implementation for websockets, partial implementation for HTTP (multipart/form-data still pending) * Add unit tests for Channels integration These unit tests are mostly copied over from FastAPI, and certainly aren't comprehensive or covering all the Channels-specific cases. However, they provide a reasonably good level of coverage for actual protocol behaviour. The HTTP consumer does not yet have any unit tests. * Add channels as dev dependency * Fix code for python 3.7 * Update docs formatting * Add release notes * Fix typo * Initial fixes for GET request * Fix http handler * fix: Handle disconnect should also reap completed tasks * test: Fix channels websockets tests * chore: Fix typing issues * refactor: Pass the original error message along instead of a custom one * fix: Fix urlpattern to handle `^graphql` instead of `^graph` * feat: Finish HttpConsumer and also implement a sync version, with full testing coverage * refactor: Inherit all handlers from the same base and better organize everything * feat: Add channels layer typing protocol * feat: Add a high level api for layers communication * docs: Document how to use the high level layers event listener * fix: Import Protocol from typing_extensions * fix: Fix a typing issue with override * fix: Fix the pyright test that just broke today * test: Cover channels integration 100% * fix: Pass response already encoded so that graphiql result doesn't get json encoded * fix: Fix should_render_graphiql checking * refactor: Handle invalid operation generically * docs: Fix a small typo on documentation * feat: Check for layers integration and give a better error message in case it is not found * docs: Add a missing comma in documentation example * check channels docs. * check channels docs - fix .md references from camelCase to no case. * check channels docs - added gql queries * add tests docs * add tests docs - added note about pytest. * Fix .md code block annotation Co-authored-by: Patrick Arminio <patrick.arminio@gmail.com> * fixed grammar more clear explanation, formatting * fix 404 * refactor: Only allow dotted access to channels context * feat: Properly type channel_listen method * channels docs - fit * update fork (#1) * Bump ddtrace from 1.2.3 to 1.3.0 (#2050) Bumps [ddtrace](https://github.com/DataDog/dd-trace-py) from 1.2.3 to 1.3.0. - [Release notes](https://github.com/DataDog/dd-trace-py/releases) - [Changelog](https://github.com/DataDog/dd-trace-py/blob/1.x/CHANGELOG.md) - [Commits](DataDog/dd-trace-py@v1.2.3...v1.3.0) --- updated-dependencies: - dependency-name: ddtrace dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump types-setuptools from 63.2.1 to 63.2.2 (#2049) Bumps [types-setuptools](https://github.com/python/typeshed) from 63.2.1 to 63.2.2. - [Release notes](https://github.com/python/typeshed/releases) - [Commits](https://github.com/python/typeshed/commits) --- updated-dependencies: - dependency-name: types-setuptools dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add support for printing dictionaries when using custom scalars (#2048) * Add support for printing dictionaries when using custom scalars * Add support for nested dicts * Add support for arguments * Add test for bool and float * Add test for id * Test for list with values * Add comment back * Fix variable * More tests * More tests for lists * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add support for objects as default values * Test more cases * Ignore code paths * Add one more test for floats Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Release 🍓 0.122.0 * Remove autoreload test (#2053) * Fix aiohttp query operation selection (#2055) * Release 🍓 0.122.1 Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Patrick Arminio <patrick.arminio@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Botberry <bot@strawberry.rocks> Co-authored-by: Jonathan Ehwald <github@ehwald.info> * Update docs/integrations/django.md Co-authored-by: Jonathan Ehwald <github@ehwald.info> * refactor: Remove not needed connection init timeout task cancellation * refactor: s/import pathlib/from pathlib import Path/ * refactor: Default groups to an empty tuple * chore: Add back channels dev dependency * test: Fix tests that broke after last change to channel_listen * docs: Add an explanation to why GraphqlWSHandler implements a handle_invalid_message method * Update strawberry/channels/handlers/http_handler.py Co-authored-by: Hans Huber <69171298+hans-brilliant@users.noreply.github.com> * test: Fix tests that broke after last change * Add log and missing marker * Update release notes * Minor docs update * Add tweet file * Docs update Co-authored-by: Patrick Arminio <patrick.arminio@gmail.com> Co-authored-by: Thiago Bellini Ribeiro <thiago@bellini.dev> Co-authored-by: Nir <88795475+nrbnlulu@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Botberry <bot@strawberry.rocks> Co-authored-by: Jonathan Ehwald <github@ehwald.info> Co-authored-by: Thiago Bellini Ribeiro <hackedbellini@gmail.com> Co-authored-by: Hans Huber <69171298+hans-brilliant@users.noreply.github.com>
This PR add support for printing dictionaries as default values, for example:
will print the following
Here's an example of this working in another server: https://codesandbox.io/s/apollo-json-default-value-4mkreh?file=/index.js:0-899
TODO:
Description
Types of Changes