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

Use Lazy class instead of raw function #10

Merged
merged 1 commit into from
Aug 19, 2023
Merged

Use Lazy class instead of raw function #10

merged 1 commit into from
Aug 19, 2023

Conversation

mizdra
Copy link
Owner

@mizdra mizdra commented Aug 19, 2023

ref: #1
follow-up: #3

Users can deserialize GraphQL custom scalar types to their favorite application types. Thus, the type of an application-level field can be any type.

For example, a custom scalar type can be deserialized into a function. However, graphql-fabbrica did not support it. graphql-fabbrica incorrectly interpreted a field deserialized into a function as a lazily evaluated field.

This PR introduces a lazy class so that graphql-fabbrica can distinguish between lazily evaluated fields and fields deserialized into functions.

References

@mizdra mizdra added the Type: Change Change existing functionality. label Aug 19, 2023
@mizdra mizdra changed the title use Lazy class instead of raw function Use Lazy class instead of raw function Aug 19, 2023
@mizdra mizdra marked this pull request as ready for review August 19, 2023 16:00
} else {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return fieldResolver as any;
Copy link
Owner Author

Choose a reason for hiding this comment

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

Previously, a cast to any type was required, but this fix removes it :).

@mizdra
Copy link
Owner Author

mizdra commented Aug 19, 2023

Frankly, I was not sure if I should support this edge case. However, the ability to eliminate the cast to any type was very appealing.

@mizdra mizdra merged commit 360747d into main Aug 19, 2023
5 checks passed
@mizdra mizdra deleted the implement-lazy branch August 19, 2023 16:06
@mizdra mizdra mentioned this pull request Aug 19, 2023
26 tasks
@mizdra mizdra mentioned this pull request Sep 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Change Change existing functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant