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

Fix misplaced parenthesis in custom scalar docs #3401

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

enoua5
Copy link
Contributor

@enoua5 enoua5 commented Feb 27, 2024

The implementation of the Base64 custom scalar given in the docs differs from the implementation actually used. The implementation currently shown in the docs raises an AttributeError when used. It appears that the docs were originally created with an extra stray close paren, and the wrong one was deleted when that was fixed.

Description

It's the user's input that needs to be encoded as bytes, not the output of base64.b64decode, which is already bytes.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Checklist

  • [n/a] My code follows the code style of this project.
  • [n/a] My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • [n/a] I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

The implementation given in the docs differs from the implementation actually used. The implementation currently shown in the docs raises an AttributeError when used. It appears that the docs were originally created with an extra stray close paren, and the wrong one was deleted when that was fixed.
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We have skipped reviewing this pull request. All the files appear to be documentation files, which we're not great at reviewing... yet!

Copy link
Member

@DoctorJohn DoctorJohn left a comment

Choose a reason for hiding this comment

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

Good spot @enoua5, thanks for the PR!

The updated code now indeed matches our internal implementiation:

Base64 = scalar(
NewType("Base64", bytes),
description=(
"Represents binary data as Base64-encoded strings, using the standard alphabet."
),
specified_by_url="https://datatracker.ietf.org/doc/html/rfc4648.html#section-4",
serialize=lambda v: base64.b64encode(v).decode("utf-8"),
parse_value=lambda v: base64.b64decode(v.encode("utf-8")),
)

@patrick91 patrick91 merged commit f33e456 into strawberry-graphql:main Feb 28, 2024
4 checks passed
@botberry
Copy link
Member

Thanks for contributing to Strawberry! 🎉 You've been invited to join
the Strawberry GraphQL organisation 😊

You can also request a free sticker by filling this form: https://forms.gle/dmnfQUPoY5gZbVT67

And don't forget to join our discord server: https://strawberry.rocks/discord 🔥

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.

None yet

4 participants