-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Support for GraphQL aliases take 2 #55
Comments
The problem of doing aliases is that typing becomes a nightmare, as you can see the current type for fields selection is already very complex, adding more will make type checking and completion slower and probably create new bugs |
Yeah I believe that. I think type tests might be able to help with regard to testing. Here is a minor example of some we did in Nexus https://github.com/graphql-nexus/nexus/blob/main/src/typegenTypeHelpers.spec.types.ts. Basically its TS type-level logic that if fails will raise compile errors during build and thus acts like a test would in CI. I'm not sure how applicable that is here though. |
I already do test types 👍 What i am saying is that the alias feature is not worth the additional complexity |
BTW Zeus supports aliases: https://github.com/graphql-editor/graphql-zeus#perform-query-with-aliases |
Aliases are needed to workaround this weird issue graphql/graphql-js#522. I am not fully convinced/understand it but alas it seems like a GQL limitation that will not be going away. |
are aliases planned at all? we're trying to figure out if we should use genql or zeus and it'll likely be the deciding factor |
Another use-case for aliases. We need to fetch workspace usage twice, for the current and the previous cycle. This seems like a perfect use-case of aliases: For the time being, batching offers a workaround: https://genql.dev/docs/usage/batching-queries, but I don't consider it ideal. |
I thought I had a use-case for #10 but then didn't. Still interested in having aliases supported though.
I can't remember right now but if we can make the types "extensible" (records with known fields) then we could treat ANY UNKNOWN key as being an alias. Its type would be a union of objects for each peer field, where each object accepts ONLY ONE.
If not, then, unfortunately:
I am pretty sure that what will happen is the record's known fields vs extensible ones will have to share the same type, and that is NOT what we want here. Thus, a third parameter would be needed.
The text was updated successfully, but these errors were encountered: