-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
RFC: Support both introspection.ts and graphql-env.d.ts #196
Comments
We're currently working on the CLI, and I think you can expect it to be integrated and solved there, by using a generate command to separately generate the file. I'll leave this RFC open with the proposal to treat it as a kind of addendum to #76. Besides that, to address the underlying concern, We've actually been working on slowly fading out the need for schema awareness in Graphcache. The reason is that while it's not outright a bad approach it has the huge downside that it can increase the runtime size of applications to an unreasonable scale, depending on schema size. By the time schema awareness was becoming expected (basically for interface types being detected correctly) a schema was already at a size where it became unreasonable to include it in the client bundle. This really puts an unreasonable decision on most users of Graphcache, when you eventually approach the limits and assumptions of “schema-less” Graphcache:
Both choices aren't great. That's why we've been slowly working on changing this. While we don't have a comprehensive plan for offline support yet (since I don't think we have the necessary feedback/info to ensure this is safe), the other two points that required schema awareness are slowly changing. You basically don't need automatic partial results any longer. Instead, The other changes we've made address union/interface types. In the latest major of Graphcache we started to change how union/interface types are stored, supplementing schema heuristics with an internal map of which types matched. That said, we believe that schema awareness will not be a “necessary evil” anymore in Graphcache going forward. I'm aware that that doesn't address type-gen and GCG’s preset for Graphcache, which is something we're still looking to eventually replace with |
The CLI has now been released. gql.tada generate-output -o introspection.ts |
Summary
urql requires a
schema
introspection object for Schema Awareness. (It vastly improves the DX for inferring__typename
, optional vs. required, etc.)However, it's only possible to have the
.d.ts
or.ts
file, not both:Proposed Solution
When providing a directory value (e.g.
./src/graphql
), bothintrospection.ts
andgraphql-env.d.ts
(new) are created.To explicitly create one or the other, the user can choose to provide an explicit path as indicated in https://gql-tada.0no.co/reference/graphqlsp-config#tadaoutputlocation.
Requirements
Looks like updating the following to do an
isDir
check & then repeating the same logic for 2 presetfileType
values:gql.tada/packages/cli-utils/src/tada.ts
Lines 41 to 47 in df302c7
The text was updated successfully, but these errors were encountered: