web-monetization-projects
web-monetization-projects copied to clipboard
chore(deps): update graphqlcodegenerator monorepo (major)
This PR contains the following updates:
Package | Type | Update | Change |
---|---|---|---|
@graphql-codegen/cli | devDependencies | major | 3.3.1 -> 5.0.0 |
@graphql-codegen/introspection | devDependencies | major | 3.0.1 -> 4.0.0 |
@graphql-codegen/typescript | devDependencies | major | 3.0.4 -> 4.0.1 |
@graphql-codegen/typescript-resolvers | devDependencies | major | 3.2.1 -> 4.0.1 |
⚠ Dependency Lookup Warnings ⚠
Warnings were logged while processing this repo. Please check the Dependency Dashboard for more information.
Release Notes
dotansimha/graphql-code-generator (@graphql-codegen/cli)
v5.0.0
Major Changes
-
#9506
dd9c7e148
Thanks @valkum! - Make @parcel/watcher optional
Patch Changes
-
#9513
fdd19d24d
Thanks @cichelero! - Update yaml dependency to 2.3.1 -
Updated dependencies [
bb1e0e96e
]:
v4.0.1
Patch Changes
-
#9479
0aa444b5d
Thanks @gilgardosh! - dependencies updates:- Updated dependency
graphql-config@^5.0.2
↗︎ (from^5.0.1
, independencies
)
- Updated dependency
-
#9479
0aa444b5d
Thanks @gilgardosh! - Update graphql-config to v^5.0.2
v4.0.0
Major Changes
Patch Changes
-
#9449
4d9ea1a5a
Thanks @n1ru4l! - dependencies updates:- Updated dependency
graphql-config@^5.0.0
↗︎ (from^4.5.0
, independencies
)
- Updated dependency
-
#9449
4d9ea1a5a
Thanks @n1ru4l! - dependencies updates:- Updated dependency
@graphql-tools/apollo-engine-loader@^8.0.0
↗︎ (from^7.3.6
, independencies
) - Updated dependency
@graphql-tools/code-file-loader@^8.0.0
↗︎ (from^7.3.17
, independencies
) - Updated dependency
@graphql-tools/git-loader@^8.0.0
↗︎ (from^7.2.13
, independencies
) - Updated dependency
@graphql-tools/github-loader@^8.0.0
↗︎ (from^7.3.28
, independencies
) - Updated dependency
@graphql-tools/graphql-file-loader@^8.0.0
↗︎ (from^7.5.0
, independencies
) - Updated dependency
@graphql-tools/json-file-loader@^8.0.0
↗︎ (from^7.4.1
, independencies
) - Updated dependency
@graphql-tools/load@^8.0.0
↗︎ (from^7.8.0
, independencies
) - Updated dependency
@graphql-tools/prisma-loader@^8.0.0
↗︎ (from^7.2.69
, independencies
) - Updated dependency
@graphql-tools/url-loader@^8.0.0
↗︎ (from^7.17.17
, independencies
) - Updated dependency
@graphql-tools/utils@^10.0.0
↗︎ (from^9.0.0
, independencies
) - Updated dependency
cosmiconfig@^8.1.3
↗︎ (from^7.0.0
, independencies
) - Updated dependency
graphql-config@^5.0.1
↗︎ (from^4.5.0
, independencies
)
- Updated dependency
-
#9371
d431f426e
Thanks @Axxxx0n! - Fixed option ignoreNoDocuments when using graphql configs -
#9275
2a5da5894
Thanks @milesrichardson! - Trigger rebuilds in watch mode while respecting rules of precedence and negation, both in terms of global (top-level) config vs. local (per-output target) config, and in terms of watch patterns (higher priority) vs. documents/schemas (lower priority). This fixes an issue with overly-aggressive rebuilds during watch mode. -
Updated dependencies [
4d9ea1a5a
,4d9ea1a5a
,f46803a8c
,63827fabe
,bb66c2a31
]:
dotansimha/graphql-code-generator (@graphql-codegen/introspection)
v4.0.0
Major Changes
Patch Changes
dotansimha/graphql-code-generator (@graphql-codegen/typescript)
v4.0.1
Patch Changes
-
#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
]:
v4.0.0
Major Changes
-
#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
Minor Changes
-
#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.
Patch Changes
dotansimha/graphql-code-generator (@graphql-codegen/typescript-resolvers)
v4.0.1
Patch Changes
-
#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
]:
v4.0.0
Major Changes
-
#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
Minor Changes
-
#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;
-
#9339
50471e651
Thanks @AaronMoat! - Add excludeTypes config to resolversNonOptionalTypenameThis disables the adding of
__typename
in resolver types for any specified typename. This could be useful e.g. if you're wanting to enable this for all new types going forward but not do a big migration.Usage example:
const config: CodegenConfig = { schema: 'src/schema/**/*.graphql', generates: { 'src/schema/types.ts': { plugins: ['typescript', 'typescript-resolvers'], config: { resolversNonOptionalTypename: { unionMember: true, excludeTypes: ['MyType'], }, }, }, }, };
-
#9229
5aa95aa96
Thanks @eddeee888! - Use generic to simplify ResolversUnionTypesThis follows the
ResolversInterfaceTypes
's approach where theRefType
generic is used to refer back toResolversTypes
orResolversParentTypes
in cases of nested Union types -
#9304
e1dc75f3c
Thanks @esfomeado! - Added support for disabling suffixes on Enums. -
#9229
5aa95aa96
Thanks @eddeee888! - Extract interfaces to ResolversInterfaceTypes and add to resolversNonOptionalTypename-
ResolversInterfaceTypes
is a new type that keeps track of a GraphQL interface and its implementing types.
For example, consider this schema:
extend type Query { character(id: ID!): CharacterNode } interface CharacterNode { id: ID! } type Wizard implements CharacterNode { id: ID! screenName: String! spells: [String!]! } type Fighter implements CharacterNode { id: ID! screenName: String! powerLevel: Int! }
The generated types will look like this:
export type ResolversInterfaceTypes<RefType extends Record<string, unknown>> = { CharacterNode: Fighter | Wizard; }; export type ResolversTypes = { // other types... CharacterNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['CharacterNode']>; Fighter: ResolverTypeWrapper<Fighter>; Wizard: ResolverTypeWrapper<Wizard>; // other types... }; export type ResolversParentTypes = { // other types... CharacterNode: ResolversInterfaceTypes<ResolversParentTypes>['CharacterNode']; Fighter: Fighter; Wizard: Wizard; // other types... };
The
RefType
generic is used to reference back toResolversTypes
andResolversParentTypes
in some cases such as field returning a Union.-
resolversNonOptionalTypename
also affectsResolversInterfaceTypes
Using the schema above, if we use
resolversNonOptionalTypename
option:const config: CodegenConfig = { schema: 'src/schema/**/*.graphql', generates: { 'src/schema/types.ts': { plugins: ['typescript', 'typescript-resolvers'], config: { resolversNonOptionalTypename: true, // Or `resolversNonOptionalTypename: { interfaceImplementingType: true }` }, }, }, };
Then, the generated type looks like this:
export type ResolversInterfaceTypes<RefType extends Record<string, unknown>> = { CharacterNode: (Fighter & { __typename: 'Fighter' }) | (Wizard & { __typename: 'Wizard' }); }; export type ResolversTypes = { // other types... CharacterNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['CharacterNode']>; Fighter: ResolverTypeWrapper<Fighter>; Wizard: ResolverTypeWrapper<Wizard>; // other types... }; export type ResolversParentTypes = { // other types... CharacterNode: ResolversInterfaceTypes<ResolversParentTypes>['CharacterNode']; Fighter: Fighter; Wizard: Wizard; // other types... };
-
Patch Changes
-
#9449
4d9ea1a5a
Thanks @n1ru4l! - dependencies updates:- Updated dependency
@graphql-tools/utils@^10.0.0
↗︎ (from^9.0.0
, independencies
)
- Updated dependency
- Updated dependencies [
4d9ea1a5a
,4d9ea1a5a
,f46803a8c
,3848a2b73
,ba84a3a27
,63827fabe
,50471e651
,5aa95aa96
,ca02ad172
,e1dc75f3c
,bb66c2a31
,5950f5a68
,5aa95aa96
]:
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.
- [ ] If you want to rebase/retry this PR, check this box
This PR has been generated by Renovate Bot.