Releases: Thinkmill/ts-gql
@ts-gql/[email protected]
@ts-gql/[email protected]
@ts-gql/[email protected]
@ts-gql/[email protected]
@ts-gql/[email protected]
@ts-gql/[email protected]
Patch Changes
- #106
69b71e4Thanks @mitchellhamilton! - Built-in scalars that haven't been overriden in thescalarsconfig will now be inlined when generating the schema input types rather than referencing the generatedScalarstype (which should not be imported outside of ts-gql's generated files).
@ts-gql/[email protected]
Patch Changes
- Updated dependencies [
ec3330f,11d562a,11d562a]:- @ts-gql/[email protected]
@ts-gql/[email protected]
Minor Changes
-
#105
11d562aThanks @mitchellhamilton! - TypeScript types for object, union and interface types are no longer generated in__generated__/ts-gql/@schema.d.ts. These types have an unclear meaning and were not intended to be used. If you relied on these types, you may want to use GraphQL Code Generator to generate those types for you. -
#105
11d562aThanks @mitchellhamilton! - The correct types are now generated to account for list input coercion in input object types(the correct types were already generated for variables) so for example, given an input object like:input SomeInput { ids: [ID!]! }
The generated TypeScript type will now be equivelent to this:
export type SomeInput = { ids: string | string[]; };
instead of what it was previously:
export type SomeInput = { ids: string[]; };
Patch Changes
- #102
ec3330fThanks @mitchellhamilton! - Fixed custom scalar types not being respected in output types
@ts-gql/[email protected]
Patch Changes
- #100
63d269dThanks @mitchellhamilton! - Fixed incorrect fix/error for casts ongqlcalls in source files in the same directory as the config.
@ts-gql/[email protected]
Minor Changes
-
#98
bc8d6ebThanks @mitchellhamilton! -ts-gql'sTypedDocumentNodetype is now compatible with@graphql-typed-document-node/core'sTypedDocumentNode.The recommended usage of ts-gql with Apollo Client is now to use
@apollo/clientdirectly. This also allows ts-gql to be used with urql and any other GraphQL client that supports@graphql-typed-document-node/core. The@ts-gql/apollopackage can still be used and may be updated in the future to avoid breakage if that makes sense but it is no longer the recommended pattern.When using
@apollo/clientover@ts-gql/apollo, it's important to note that some type safety will be lost:- Variables are always optional so omitting variables when they are required will no longer be caught by TypeScript
refetchQuerieswill accept any string so passing names to queries that don't exist will not cause a TypeScript error. You should likely pass in the document with the query itself to avoid mis-typing query names causing errors.
Because
@graphql-typed-document-node/core'sTypedDocumentNodeextendsgraphql'sDocumentNode, this means thatgetDocumentNodefrom@ts-gql/tagis no longer necessary. This could be another cause for bugs if there are two APIs, one that accepts aTypedDocumentNodethat you should use and another that acceptsDocumentNodewhich you shouldn't use, you could accidentally use the API that acceptsDocumentNodeover the one that acceptsTypedDocumentNodewhere previously you would get an error when passing aTypedDocumentNodeto something accepting aDocumentNode.Context behind this change
When ts-gql was originally written,
@graphql-typed-document-node/coredid not exist. Since then,@graphql-typed-document-node/corehas become used by Apollo Client and urql. Given that, maintaining types to adapt Apollo Client to ts-gql'sTypedDocumentNodeseems less sensible.While this does mean that some of ts-gql's safety is reduced, this seems like an appropriate trade-off so that ts-gql can reduce maintaince burden, avoid imposing opinions on top of GraphQL clients and support more GraphQL clients without having to write types for them specifically.