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

Convert Tuple and Sequence types to GraphQL List types #2164

Merged

Conversation

jkimbo
Copy link
Member

@jkimbo jkimbo commented Sep 12, 2022

To help with typing resolvers correctly, this PR updates the logic to
determine if an annotation is GraphQL List type by checking against the
Tuple and Sequence types.

Fixes #2035 and #2161

Diff-Id: e22a7

@codecov
Copy link

codecov bot commented Sep 12, 2022

Codecov Report

Merging #2164 (42db728) into main (6034cde) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #2164   +/-   ##
=======================================
  Coverage   98.21%   98.21%           
=======================================
  Files         162      162           
  Lines        6460     6460           
  Branches     1226     1226           
=======================================
  Hits         6345     6345           
  Misses         58       58           
  Partials       57       57           

@botberry
Copy link
Member

botberry commented Sep 12, 2022

Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:


Convert Tuple and Sequence types to GraphQL list types.

Example:

from collections.abc import Sequence
from typing import Tuple

@strawberry.type
class User:
    pets: Sequence[Pet]
    favourite_ice_cream_flavours: Tuple[IceCreamFlavour]

Here's the preview release card for twitter:

Here's the tweet text:

🆕 Release (next) is out! Thanks to Jonathan Kim for the PR 👏

Get it here 👉 https://github.com/strawberry-graphql/strawberry/releases/tag/(next)

To help with typing resolvers correctly, this PR updates the logic to
determine if an annotation is GraphQL List type by checking against the
Tuple and Sequence types.

Fixes #2035 and #2161

Diff-Id: e22a7
@jkimbo jkimbo force-pushed the convert-tuple-and-sequence-types-to-graphql-list-types branch from c373f4b to b991115 Compare September 12, 2022 09:45
Copy link
Member

@patrick91 patrick91 left a comment

Choose a reason for hiding this comment

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

Thank you!

@patrick91 patrick91 merged commit cd6a44b into main Sep 12, 2022
@patrick91 patrick91 deleted the convert-tuple-and-sequence-types-to-graphql-list-types branch September 12, 2022 10:42
@dperetti
Copy link

Unfortunately, it doesn't handle the case where the tuple is Tuple[Date, float] for instance.

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.

Allow using tuple (and/or iterable) as an alias to the GraphQL type
4 participants