-
#9842
ed9c205
Thanks @henryqdineen! - properly handle aliased conditionals -
Updated dependencies [
920b443
,ed9c205
]:- @graphql-codegen/visitor-plugin-common@5.1.0
- @graphql-codegen/typescript@4.0.6
- Updated dependencies [
53f270a
]:- @graphql-codegen/visitor-plugin-common@5.0.0
- @graphql-codegen/typescript@4.0.5
-
Updated dependencies [
4e69568
]:- @graphql-codegen/visitor-plugin-common@4.1.2
- @graphql-codegen/typescript@4.0.4
- @graphql-codegen/plugin-helpers@5.0.3
- Updated dependencies [
7718a8113
]:- @graphql-codegen/visitor-plugin-common@4.1.1
- @graphql-codegen/typescript@4.0.3
- #9811
d8364e045
Thanks @saihaj! - fix: out-of-memory crash (fixes #7720) perf: implement a caching mechanism that makes sure the type originating at the same location is never generated twice, as long as the combination of selected fields and possible types matches feat: implementextractAllFieldsToTypes: boolean
feat: implementprintFieldsOnNewLines: boolean
- #9811
d8364e045
Thanks @saihaj! - dependencies updates:- Updated dependency
tslib@~2.6.0
↗︎ (from~2.5.0
, independencies
)
- Updated dependency
- Updated dependencies [
d8364e045
,d8364e045
,d8364e045
,d8364e045
,d8364e045
]:- @graphql-codegen/plugin-helpers@5.0.2
- @graphql-codegen/typescript@4.0.2
- @graphql-codegen/visitor-plugin-common@4.1.0
-
#9497
2276708d0
Thanks @eddeee888! - Revert default ID scalar input type to stringWe changed the ID Scalar input type from
string
tostring | number
in the latest major version oftypescript
plugin. This causes issues for server plugins (e.g. typescript-resolvers) that depends ontypescript
plugin. This is because the scalar type needs to be manually inverted on setup which is confusing. -
Updated dependencies [
2276708d0
]:- @graphql-codegen/visitor-plugin-common@4.0.1
- @graphql-codegen/typescript@4.0.1
-
#9375
ba84a3a27
Thanks @eddeee888! - Implement Scalars with input/output typesIn GraphQL, Scalar types can be different for client and server. For example, given the native GraphQL ID:
- A client may send
string
ornumber
in the input - A client receives
string
in its selection set (i.e output) - A server receives
string
in the resolver (GraphQL parsesstring
ornumber
received from the client tostring
) - A server may return
string
ornumber
(GraphQL serializes the value tostring
before sending it to the client )
Currently, we represent every Scalar with only one type. This is what codegen generates as base type:
export type Scalars = { ID: string; };
Then, this is used in both input and output type e.g.
export type Book = { __typename?: 'Book'; id: Scalars['ID']; // Output's ID can be `string` 👍 }; export type QueryBookArgs = { id: Scalars['ID']; // Input's ID can be `string` or `number`. However, the type is only `string` here 👎 };
This PR extends each Scalar to have input and output:
export type Scalars = { ID: { input: string | number; output: string; }; };
Then, each input/output GraphQL type can correctly refer to the correct input/output scalar type:
export type Book = { __typename?: 'Book'; id: Scalars['ID']['output']; // Output's ID can be `string` 👍 }; export type QueryBookArgs = { id: Scalars['ID']['input']; // Input's ID can be `string` or `number` 👍 };
Note that for
typescript-resolvers
, the type of ID needs to be inverted. However, the referenced types in GraphQL input/output types should still work correctly:export type Scalars = { ID: { input: string; output: string | number; } } export type Book = { __typename?: "Book"; id: Scalars["ID"]['output']; // Resolvers can return `string` or `number` in ID fields 👍 }; export type QueryBookArgs = { id: Scalars["ID"]['input']; // Resolvers receive `string` in ID fields 👍 }; export type ResolversTypes = { ID: ID: ResolverTypeWrapper<Scalars['ID']['output']>; // Resolvers can return `string` or `number` in ID fields 👍 } export type ResolversParentTypes = { ID: Scalars['ID']['output']; // Resolvers receive `string` or `number` from parents 👍 };
Config changes:
- Scalars option can now take input/output types:
config: { scalars: { ID: { input: 'string', output: 'string | number' } } }
- If a string is given (instead of an object with input/output fields), it will be used as both input and output types:
config: { scalars: { ID: 'string'; // This means `string` will be used for both ID's input and output types } }
- BREAKING CHANGE: External module Scalar types need to be an object with input/output fields
config: { scalars: { ID: './path/to/scalar-module'; } }
If correctly, wired up, the following will be generated:
// Previously, imported `ID` type can be a primitive type, now it must be an object with input/output fields import { ID } from './path/to/scalar-module'; export type Scalars = { ID: { input: ID['input']; output: ID['output'] }; };
BREAKING CHANGE: This changes Scalar types which could be referenced in other plugins. If you are a plugin maintainer and reference Scalar, please update your plugin to use the correct input/output types.
- A client may send
-
bb66c2a31
Thanks @n1ru4l! - Require Node.js>= 16
. Drop support for Node.js 14
-
#9196
3848a2b73
Thanks @beerose! - Add@defer
directive supportWhen a query includes a deferred fragment field, the server will return a partial response with the non-deferred fields first, followed by the remaining fields once they have been resolved.
Once start using the
@defer
directive in your queries, the generated code will automatically include support for the directive.// src/index.tsx import { graphql } from './gql'; const OrdersFragment = graphql(` fragment OrdersFragment on User { orders { id total } } `); const GetUserQuery = graphql(` query GetUser($id: ID!) { user(id: $id) { id name ...OrdersFragment @defer } } `);
The generated type for
GetUserQuery
will have information that the fragment is incremental, meaning it may not be available right away.// gql/graphql.ts export type GetUserQuery = { __typename?: 'Query'; id: string; name: string } & ({ __typename?: 'Query'; } & { ' $fragmentRefs'?: { OrdersFragment: Incremental<OrdersFragment> }; });
Apart from generating code that includes support for the
@defer
directive, the Codegen also exports a utility function calledisFragmentReady
. You can use it to conditionally render components based on whether the data for a deferred fragment is available:const OrdersList = (props: { data: FragmentType<typeof OrdersFragment> }) => { const data = useFragment(OrdersFragment, props.data); return ( // render orders list ) }; function App() { const { data } = useQuery(GetUserQuery); return ( {data && ( <> {isFragmentReady(GetUserQuery, OrdersFragment, data) && <OrdersList data={data} />} </> )} ); } export default App;
-
#9304
e1dc75f3c
Thanks @esfomeado! - Added support for disabling suffixes on Enums.
- Updated dependencies [
4d9ea1a5a
,4d9ea1a5a
,f46803a8c
,3848a2b73
,ba84a3a27
,63827fabe
,50471e651
,5aa95aa96
,ca02ad172
,e1dc75f3c
,bb66c2a31
,5950f5a68
,5aa95aa96
]:- @graphql-codegen/plugin-helpers@5.0.0
- @graphql-codegen/visitor-plugin-common@4.0.0
- @graphql-codegen/typescript@4.0.0
- Updated dependencies [
386cf9044
,402cb8ac0
]:- @graphql-codegen/visitor-plugin-common@3.1.1
- @graphql-codegen/typescript@3.0.4
- Updated dependencies [
e56790104
,b7dacb21f
,f104619ac
,92d86b009
,acb647e4e
,9f4d9c5a4
]:- @graphql-codegen/visitor-plugin-common@3.1.0
- @graphql-codegen/plugin-helpers@4.2.0
- @graphql-codegen/typescript@3.0.3
- Updated dependencies [
ba0610bbd
,4b49f6fbe
,b343626c9
]:- @graphql-codegen/visitor-plugin-common@3.0.2
- @graphql-codegen/typescript@3.0.2
- #8879
8206b268d
Thanks @renovate! - dependencies updates:- Updated dependency
tslib@~2.5.0
↗︎ (from~2.4.0
, independencies
)
- Updated dependency
- Updated dependencies [
8206b268d
,8206b268d
,8206b268d
,a118c307a
,6b6fe3cbc
,a3309e63e
]:- @graphql-codegen/plugin-helpers@4.1.0
- @graphql-codegen/typescript@3.0.1
- @graphql-codegen/visitor-plugin-common@3.0.1
- Updated dependencies [
fc79b65d4
,fd0b0c813
]:- @graphql-codegen/visitor-plugin-common@3.0.0
- @graphql-codegen/plugin-helpers@4.0.0
- @graphql-codegen/typescript@3.0.0
- Updated dependencies [
a98198524
]:- @graphql-codegen/visitor-plugin-common@2.13.8
- @graphql-codegen/typescript@2.8.8
- Updated dependencies [
eb454d06c
]:- @graphql-codegen/visitor-plugin-common@2.13.7
- @graphql-codegen/typescript@2.8.7
- Updated dependencies [
ed87c782b
,ed87c782b
,6c6b6f2df
]:- @graphql-codegen/plugin-helpers@3.1.2
- @graphql-codegen/visitor-plugin-common@2.13.6
- @graphql-codegen/typescript@2.8.6
-
46f75304a
Thanks @saihaj! - fix the version of@graphql-codegen/plugin-helpers@3.1.1
-
Updated dependencies [
307a5d350
,46f75304a
]:- @graphql-codegen/plugin-helpers@3.1.1
- @graphql-codegen/visitor-plugin-common@2.13.5
- @graphql-codegen/typescript@2.8.5
- Updated dependencies [
a6c2097f4
,a6c2097f4
,f79a00e8a
,c802a0c0b
]:- @graphql-codegen/plugin-helpers@3.0.0
- @graphql-codegen/visitor-plugin-common@2.13.4
- @graphql-codegen/typescript@2.8.4
-
#8664
62f655452
Thanks @jdmoody! - Fix issue where selection set flattening uses the wrong parent type -
Updated dependencies [
62f655452
]:- @graphql-codegen/visitor-plugin-common@2.13.3
- @graphql-codegen/typescript@2.8.3
- Updated dependencies [
ef4c2c9c2
]:- @graphql-codegen/visitor-plugin-common@2.13.2
- @graphql-codegen/typescript@2.8.2
- Updated dependencies [
63dc8f205
]:- @graphql-codegen/visitor-plugin-common@2.13.1
- @graphql-codegen/plugin-helpers@2.7.2
- @graphql-codegen/typescript@2.8.1
- Updated dependencies [
a46b8d99c
]:- @graphql-codegen/visitor-plugin-common@2.13.0
- @graphql-codegen/typescript@2.7.5
- Updated dependencies [
1bd7f771c
]:- @graphql-codegen/visitor-plugin-common@2.12.2
- @graphql-codegen/typescript@2.7.4
-
#8189
b408f8238
Thanks @n1ru4l! - Fix CommonJS TypeScript resolution withmoduleResolution
node16
ornodenext
-
Updated dependencies [
b408f8238
,47d0a57e2
]:- @graphql-codegen/visitor-plugin-common@2.12.1
- @graphql-codegen/typescript@2.7.3
- @graphql-codegen/plugin-helpers@2.6.2
- Updated dependencies [2cbcbb371]
- @graphql-codegen/visitor-plugin-common@2.12.0
- @graphql-codegen/plugin-helpers@2.6.0
- @graphql-codegen/typescript@2.7.2
- Updated dependencies [525ad580b]
- @graphql-codegen/visitor-plugin-common@2.11.1
- @graphql-codegen/typescript@2.7.1
-
d84afec09: Support TypeScript ESM modules (
"module": "node16"
and"moduleResolution": "node16"
).
- Updated dependencies [68bb30e19]
- Updated dependencies [d84afec09]
- Updated dependencies [a4fe5006b]
- Updated dependencies [8e44df58b]
- @graphql-codegen/visitor-plugin-common@2.11.0
- @graphql-codegen/typescript@2.7.0
- @graphql-codegen/plugin-helpers@2.5.0
- Updated dependencies [aa1e6eafd]
- Updated dependencies [a42fcbfe4]
- Updated dependencies [8b10f22be]
- @graphql-codegen/typescript@2.6.0
- @graphql-codegen/visitor-plugin-common@2.10.0
- Updated dependencies [d16bebacb]
- @graphql-codegen/visitor-plugin-common@2.9.1
- @graphql-codegen/typescript@2.5.1
- Updated dependencies [c3d7b7226]
- @graphql-codegen/visitor-plugin-common@2.9.0
- @graphql-codegen/typescript@2.5.0
- f1fb77bd4: feat: Add option to squash exactly similar fragment types
- Updated dependencies [f1fb77bd4]
- @graphql-codegen/visitor-plugin-common@2.8.0
- @graphql-codegen/typescript@2.4.11
- Updated dependencies [9a5f31cb6]
- @graphql-codegen/typescript@2.4.10
- @graphql-codegen/visitor-plugin-common@2.7.6
- 9312920a4: Import type definitions of dependent fragments when
inlineFragmentType
ismask
- 2966686e9: Generate $fragmentName for fragment subtypes for fragment masking
- Updated dependencies [2966686e9]
- @graphql-codegen/visitor-plugin-common@2.7.5
- @graphql-codegen/typescript@2.4.9
- Updated dependencies [337fd4f77]
- @graphql-codegen/visitor-plugin-common@2.7.4
- @graphql-codegen/typescript@2.4.8
- Updated dependencies [54718c039]
- @graphql-codegen/typescript@2.4.7
- @graphql-codegen/visitor-plugin-common@2.7.3
- Updated dependencies [11d05e361]
- @graphql-codegen/visitor-plugin-common@2.7.2
- @graphql-codegen/typescript@2.4.6
- fd55e2039: fix incorrect type generation when using the inlineFragmentTypes 'combine' option that resulted in generating masked fragment output.
- Updated dependencies [fd55e2039]
- @graphql-codegen/visitor-plugin-common@2.7.1
- @graphql-codegen/typescript@2.4.5
- Updated dependencies [1479233df]
- @graphql-codegen/visitor-plugin-common@2.7.0
- @graphql-codegen/typescript@2.4.4
- 4d413b13a: feat: Support including fragments when using flattenGeneratedTypes in typescript-operations
- Updated dependencies [c8ef37ae0]
- Updated dependencies [754a33715]
- Updated dependencies [bef4376d5]
- Updated dependencies [be7cb3a82]
- @graphql-codegen/visitor-plugin-common@2.6.0
- @graphql-codegen/plugin-helpers@2.4.0
- @graphql-codegen/typescript@2.4.3
- 7649201fe: Remove redundant mandatory 'undefined' on avoidOptionals=true
- 6002feb3d: Fix exports in package.json files for react-native projects
- Updated dependencies [6002feb3d]
- @graphql-codegen/visitor-plugin-common@2.5.2
- @graphql-codegen/typescript@2.4.2
- @graphql-codegen/plugin-helpers@2.3.2
- a9f1f1594: Use maybeValue as default output for optionals on preResolveTypes: true
- Updated dependencies [a9f1f1594]
- Updated dependencies [9ea6621ec]
- @graphql-codegen/visitor-plugin-common@2.5.1
- @graphql-codegen/typescript@2.4.1
- 97ddb487a: feat: GraphQL v16 compatibility
- Updated dependencies [97ddb487a]
- @graphql-codegen/visitor-plugin-common@2.5.0
- @graphql-codegen/typescript@2.3.0
- @graphql-codegen/plugin-helpers@2.3.0
- 8a576b49a: avoidOptionals with skip/include directives fix
- Updated dependencies [ad02cb9b8]
- @graphql-codegen/visitor-plugin-common@2.4.0
- @graphql-codegen/typescript@2.2.4
- 1d570b456: avoidOptionals sub-config fix
- Updated dependencies [b9e85adae]
- Updated dependencies [7c60e5acc]
- Updated dependencies [3c2c847be]
- @graphql-codegen/visitor-plugin-common@2.3.0
- @graphql-codegen/plugin-helpers@2.2.0
- @graphql-codegen/typescript@2.2.3
- 5c37b9d11: Fix avoidOptional handle of Maybe types
- 25cd11d01: correctly inline Maybe types if the
preresolveTypes
config option is set totrue
- Updated dependencies [0b090e31a]
- @graphql-codegen/visitor-plugin-common@2.2.1
- @graphql-codegen/typescript@2.2.2
- Updated dependencies [d6c2d4c09]
- Updated dependencies [feeae1c66]
- Updated dependencies [8261e4161]
- Updated dependencies [5086791ac]
- @graphql-codegen/visitor-plugin-common@2.2.0
- @graphql-codegen/typescript@2.2.0
- Updated dependencies [6470e6cc9]
- Updated dependencies [263570e50]
- Updated dependencies [35199dedf]
- @graphql-codegen/visitor-plugin-common@2.1.2
- @graphql-codegen/plugin-helpers@2.1.1
- @graphql-codegen/typescript@2.1.2
- Updated dependencies [aabeff181]
- @graphql-codegen/visitor-plugin-common@2.1.1
- @graphql-codegen/typescript@2.1.1
- 440172cfe: support ESM
- Updated dependencies [290170262]
- Updated dependencies [24185985a]
- Updated dependencies [39773f59b]
- Updated dependencies [440172cfe]
- @graphql-codegen/visitor-plugin-common@2.1.0
- @graphql-codegen/plugin-helpers@2.1.0
- @graphql-codegen/typescript@2.1.0
- e8c8e9c06: Set
preResolveTypes: true
by default (should be there since v2)
-
d80efdec4: Change
preResolveTypes
default to betrue
for more readable types -
b0cb13df4: Update to latest
graphql-tools
andgraphql-config
version.‼️ ‼️ ‼️ Please note‼️ ‼️ ‼️ :This is a breaking change since Node 10 is no longer supported in
graphql-tools
, and also no longer supported for Codegen packages.
-
d80efdec4: Add option
inlineFragmentTypes
for deep inlining fragment types within operation types. ThisinlineFragmentTypes
is set toinline
by default (Previous behaviour iscombine
).This behavior is the better default for users that only use Fragments for building operations and then want to have access to all the data via the operation type (instead of accessing slices of the data via fragments).
-
Updated dependencies [d80efdec4]
-
Updated dependencies [d80efdec4]
-
Updated dependencies [b0cb13df4]
- @graphql-codegen/visitor-plugin-common@2.0.0
- @graphql-codegen/typescript@2.0.0
- @graphql-codegen/plugin-helpers@2.0.0
- Updated dependencies [df19a4ed]
- Updated dependencies [470336a1]
- Updated dependencies [9005cc17]
- @graphql-codegen/visitor-plugin-common@1.22.0
- @graphql-codegen/plugin-helpers@1.18.8
- @graphql-codegen/typescript@1.23.0
- 6762aff5: Fix for array types with @skip @include directives
- Updated dependencies [6762aff5]
- @graphql-codegen/visitor-plugin-common@1.21.3
- @graphql-codegen/typescript@1.22.4
- 6aaecf1c: Fix issues with missing sub-fragments when skipTypename: true
- Updated dependencies [6aaecf1c]
- @graphql-codegen/visitor-plugin-common@1.21.2
- @graphql-codegen/typescript@1.22.3
- Updated dependencies [cf1e5abc]
- @graphql-codegen/visitor-plugin-common@1.21.1
- @graphql-codegen/typescript@1.22.2
- 0a909869: Add arrayInputCoercion option
- Updated dependencies [dfd25caf]
- Updated dependencies [8da7dff6]
- @graphql-codegen/visitor-plugin-common@1.21.0
- @graphql-codegen/plugin-helpers@1.18.7
- @graphql-codegen/typescript@1.22.1
- d9212aa0: fix(visitor-plugin-common): guard for a runtime type error
- Updated dependencies [d9212aa0]
- Updated dependencies [f0b5ea53]
- Updated dependencies [097bea2f]
- @graphql-codegen/visitor-plugin-common@1.20.0
- @graphql-codegen/typescript@1.22.0
- @graphql-codegen/plugin-helpers@1.18.5
- 1f6f3db6: Fix for @skip @include directives upon arrays
- 29b75b1e: enhance(namingConvention): use change-case-all instead of individual packages for naming convention
- Updated dependencies [e947f8e3]
- Updated dependencies [29b75b1e]
- Updated dependencies [d4942d04]
- Updated dependencies [1f6f3db6]
- Updated dependencies [29b75b1e]
- @graphql-codegen/visitor-plugin-common@1.19.0
- @graphql-codegen/typescript@1.21.1
- @graphql-codegen/plugin-helpers@1.18.3
- 63be0f40: Fix issues with empty interfaces causing syntax issues
- 190482a1: add support for fragment variables
- 142b32b3: @skip, @include directives resolve to optional fields
- 142b32b3: Better support for @skip/@include directives with complex selection sets
- Updated dependencies [63be0f40]
- Updated dependencies [190482a1]
- Updated dependencies [4444348d]
- Updated dependencies [142b32b3]
- Updated dependencies [42213fa0]
- @graphql-codegen/visitor-plugin-common@1.18.1
- @graphql-codegen/typescript@1.20.1
- 64293437: Support for input lists coercion
- Updated dependencies [64293437]
- Updated dependencies [fd5843a7]
- Updated dependencies [d75051f5]
- @graphql-codegen/visitor-plugin-common@1.17.22
- 1183d173: Bump all packages to resolve issues with shared dependencies
- Updated dependencies [1183d173]
- @graphql-codegen/visitor-plugin-common@1.17.20
- @graphql-codegen/typescript@1.18.1
- @graphql-codegen/plugin-helpers@1.18.2
- 7587fda4: When using avoidOptionals config, @skip, @include resolve into MakeMaybe type
- Updated dependencies [99819bf1]
- Updated dependencies [49242c20]
- Updated dependencies [c3b59e81]
- @graphql-codegen/visitor-plugin-common@1.17.19
- @graphql-codegen/typescript@1.18.0
- 475aa9b8: @skip, @include directives resolve to optional fields
- Updated dependencies [faa13973]
- @graphql-codegen/visitor-plugin-common@1.17.18
- 612e5e52: Remove broken isTypeOf call (always undefined in graphql-tools v6)
- 0f35e775: Fixed issues with incorrect naming when typesSuffix is used
- Updated dependencies [612e5e52]
- Updated dependencies [9f2a4e2f]
- Updated dependencies [0f35e775]
- Updated dependencies [eaf45d1f]
- @graphql-codegen/visitor-plugin-common@1.17.17
- @graphql-codegen/plugin-helpers@1.18.1
- 1d7c6432: Bump all packages to allow "^" in deps and fix compatibility issues
- 1d7c6432: Bump versions of @graphql-tools/ packages to fix issues with loading schemas and SDL comments
- Updated dependencies [1d7c6432]
- Updated dependencies [1d7c6432]
- @graphql-codegen/visitor-plugin-common@1.17.13
- @graphql-codegen/plugin-helpers@1.17.8
- @graphql-codegen/typescript@1.17.8