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

Refactor ID to add formatter via placeholder #4669

Closed
benmccallum opened this issue Jan 19, 2022 · 1 comment
Closed

Refactor ID to add formatter via placeholder #4669

benmccallum opened this issue Jan 19, 2022 · 1 comment
Labels
Area: Relay Issue is related to the Relay integration 🎉 enhancement New feature or request 🌶️ hot chocolate
Milestone

Comments

@benmccallum
Copy link
Collaborator

Is your feature request related to a problem?

It's currently impossible (AFAIK) to determine whether an argument / input field has been setup as an ID field in cases where the [ID] attribute isn't used (which can be spotted in reflection).

Currently the way that polymorphic ids library does it is to look for the attribute, but we can't support fluent-style setup using .ID()
Code.

The ID descriptor extensions set it up in OnBeforeCompleteType, so I can't look for the GlobalIdInputFormatter on args to know if the arg/field is an ID (and insert mine before it). There's essentially a race condition.

The solution you'd like

On a call Michael said it'd be good to refactor this to use the same technique that some field middleware is added, like UsePaging, by having the extension method insert a placeholder formatter and swapping the real one in later in the type interceptor.

  • WellKnownFormatterNames/WellKnownFormatterTypes.GlobalIdInputValueFormatter would mean we could look for it as an external library.

Alternatively, all the ID descriptor extensions could add a flag into the temporary context data I suppose.

Product

Hot Chocolate

@michaelstaib
Copy link
Member

We have now named fromatters so you can inspect the configuration for them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Relay Issue is related to the Relay integration 🎉 enhancement New feature or request 🌶️ hot chocolate
Projects
None yet
Development

No branches or pull requests

3 participants