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

Can we infer bounds on generic QueryFragments #709

Open
obmarg opened this issue Jun 9, 2023 · 1 comment · May be fixed by #893
Open

Can we infer bounds on generic QueryFragments #709

obmarg opened this issue Jun 9, 2023 · 1 comment · May be fixed by #893
Labels
✨ enhancement New feature or request
Milestone

Comments

@obmarg
Copy link
Owner

obmarg commented Jun 9, 2023

#708 asked if it's possible to make the response type in a QueryFragment generic. It seems possible at the moment, but you have to specify bounds on the generic parameters (and the variable fields type - which is a bit unclear) to get it to work.

I'm wondering if it would be possible to add these bounds automatically... Needs some thought - my initial experiment suggests it would be possible, but there might be some downsides that need to be considered.

In particular we'd need to be careful to only add bounds for types that actually need them - seems like it would be possible to have a parameter that didn't need to be QueryFragment, so need to make sure we don't add bounds on those parameters.

@obmarg obmarg added the ✨ enhancement New feature or request label Jun 9, 2023
@obmarg obmarg added this to the 4.0.0 milestone Jun 11, 2023
@obmarg
Copy link
Owner Author

obmarg commented Jan 9, 2024

I think the logic for this is roughly:

  • Walk the struct definition looking to see which field(s) each generic parameter is used on.
  • Any field that is unambiguously some GraphQL schema type should get variable match & query fragment bounds added to the QueryFragment impl where clause.
    • Excluding fields that appear in conflicting positions in the struct.
    • Possibly excluding cases where we can't figure out the arity, or otherwise have difficulty being sure?

@obmarg obmarg linked a pull request Apr 6, 2024 that will close this issue
@obmarg obmarg closed this as completed Jun 8, 2024
@obmarg obmarg reopened this Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant