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

feat!: add a default global ID encoder, add a id_field on the query type #1227

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

pkucmus
Copy link
Contributor

@pkucmus pkucmus commented Feb 4, 2025

BREAKING CHANGE: the global ID function takes only a str with the GID, the query type uses the id_field arg to determine which kwarg to pass to the decoder

One would be able to do:

query = RelayQueryType(
    id_field="bid",
)

Instead of this:

def decode_global_id(kwargs) -> GlobalIDTuple:
    return GlobalIDTuple(*b64decode(kwargs["bid"]).decode().split(":"))


query = RelayQueryType(
    global_id_decoder=decode_global_id,
)

With the following:

type_name, _ = self.global_id_decoder(kwargs[self.id_field])

This is to make the decoder a bit dummer as to take the responsibility of pulling the GID from the right kwarg (or query param, if you will) from the decoder and leave it with the single responsibility.

BREAKING CHANGE: the global ID function takes only a str with the GID, the query type uses the `id_field` arg to determine which kwarg to pass to the decoder
@pkucmus pkucmus merged commit 65f918c into main Feb 7, 2025
20 checks passed
@pkucmus pkucmus deleted the feature/relay branch February 7, 2025 12:14
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.

2 participants