From 191e0ca572d860dc4c059123a2f2354587216191 Mon Sep 17 00:00:00 2001 From: Dotan Simha Date: Sun, 7 Mar 2021 19:02:13 +0200 Subject: [PATCH] update all examples and all docs --- .../typescript/generic-sdk/src/config.ts | 3 + packages/utils/config-schema/src/plugins.ts | 5 + website/docs/generated-config/add.md | 2 +- .../generated-config/c-sharp-operations.md | 2 + .../docs/generated-config/flow-operations.md | 52 ++-- .../docs/generated-config/flow-resolvers.md | 8 + website/docs/generated-config/flow.md | 32 +- .../generated-config/java-apollo-android.md | 48 +-- .../docs/generated-config/java-resolvers.md | 80 ++--- website/docs/generated-config/java.md | 80 ++--- website/docs/generated-config/kotlin.md | 42 +-- .../named-operations-object.md | 9 +- website/docs/generated-config/time.md | 24 +- .../typescript-apollo-angular.md | 2 + .../typescript-compatibility.md | 40 +-- .../typescript-document-nodes.md | 52 ++-- .../typescript-generic-sdk.md | 287 ++++++++++++++++++ .../typescript-graphql-request.md | 20 +- .../generated-config/typescript-mongodb.md | 50 +-- .../typescript-react-apollo.md | 2 + .../generated-config/typescript-resolvers.md | 142 +++++---- .../typescript-stencil-apollo.md | 6 +- .../docs/generated-config/typescript-urql.md | 6 +- .../generated-config/typescript-vue-apollo.md | 2 + website/docs/plugins/index.md | 1 + .../docs/plugins/typescript-generic-sdk.md | 15 + website/sidebars.js | 1 + website/static/config.schema.json | 225 +++++++++++--- 28 files changed, 871 insertions(+), 367 deletions(-) create mode 100644 website/docs/generated-config/typescript-generic-sdk.md create mode 100644 website/docs/plugins/typescript-generic-sdk.md diff --git a/packages/plugins/typescript/generic-sdk/src/config.ts b/packages/plugins/typescript/generic-sdk/src/config.ts index aec8d004799..fd5b3f1c822 100644 --- a/packages/plugins/typescript/generic-sdk/src/config.ts +++ b/packages/plugins/typescript/generic-sdk/src/config.ts @@ -1,5 +1,8 @@ import { RawClientSideBasePluginConfig } from '@graphql-codegen/visitor-plugin-common'; +/** + * This plugin generate a generic SDK (without any Requester implemented), allow you to easily customize the way you fetch your data, without loosing the strongly-typed integration. + */ export interface RawGenericSdkPluginConfig extends RawClientSideBasePluginConfig { /** * usingObservableFrom: "import Observable from 'zen-observable';" diff --git a/packages/utils/config-schema/src/plugins.ts b/packages/utils/config-schema/src/plugins.ts index baac9d8eb6e..7362c939d0b 100644 --- a/packages/utils/config-schema/src/plugins.ts +++ b/packages/utils/config-schema/src/plugins.ts @@ -25,6 +25,11 @@ export const pluginsConfigurations: PluginConfig[] = [ identifier: 'ReactQueryRawPluginConfig', name: 'typescript-react-query', }, + { + file: '../../plugins/typescript/generic-sdk/src/config.ts', + identifier: 'RawGenericSdkPluginConfig', + name: 'typescript-generic-sdk', + }, { file: '../../plugins/typescript/apollo-client-helpers/src/config.ts', identifier: 'ApolloClientHelpersConfig', diff --git a/website/docs/generated-config/add.md b/website/docs/generated-config/add.md index 068d3891708..13df3f42204 100644 --- a/website/docs/generated-config/add.md +++ b/website/docs/generated-config/add.md @@ -24,5 +24,5 @@ Allow you to choose where to add the content. type: `Types.RequireExtension` -The actual content you wish to add, either a string or array of strings. +The actual content you wish to add, either a string or array of strings. You can also specify a path to a local file and the content if it will be loaded by codegen. diff --git a/website/docs/generated-config/c-sharp-operations.md b/website/docs/generated-config/c-sharp-operations.md index f32c204167b..f80bc39c06d 100644 --- a/website/docs/generated-config/c-sharp-operations.md +++ b/website/docs/generated-config/c-sharp-operations.md @@ -211,6 +211,8 @@ Declares how DocumentNode are created: - `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them. - `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom` +Note that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter. + ### `optimizeDocumentNode` diff --git a/website/docs/generated-config/flow-operations.md b/website/docs/generated-config/flow-operations.md index 919c580ca87..d54142dcfc2 100644 --- a/website/docs/generated-config/flow-operations.md +++ b/website/docs/generated-config/flow-operations.md @@ -1,7 +1,7 @@ -This plugin generates Flow types based on your `GraphQLSchema` and your GraphQL operations and fragments. - -It generates types for your GraphQL documents: Query, Mutation, Subscription and Fragment. - +This plugin generates Flow types based on your `GraphQLSchema` and your GraphQL operations and fragments. + +It generates types for your GraphQL documents: Query, Mutation, Subscription and Fragment. + This plugin requires you to use `@graphql-codegen/flow` as well, because it depends on it's types. ## Installation @@ -27,13 +27,13 @@ Generates Flow types as Exact types. #### Usage Examples -```yml -generates: -path/to/file.ts: - plugins: - - flow - config: - useFlowExactObjects: false +```yml +generates: +path/to/file.ts: + plugins: + - flow + config: + useFlowExactObjects: false ``` ### `useFlowReadOnlyTypes` @@ -45,13 +45,13 @@ Generates read-only Flow types #### Usage Examples -```yml -generates: -path/to/file.ts: - plugins: - - flow - config: - useFlowReadOnlyTypes: true +```yml +generates: +path/to/file.ts: + plugins: + - flow + config: + useFlowReadOnlyTypes: true ``` ### `flattenGeneratedTypes` @@ -63,14 +63,14 @@ Flatten fragment spread and inline fragments into a simple selection set before #### Usage Examples -```yml -generates: -path/to/file.ts: - plugins: - - typescript - - typescript-operations - config: - flattenGeneratedTypes: true +```yml +generates: +path/to/file.ts: + plugins: + - typescript + - typescript-operations + config: + flattenGeneratedTypes: true ``` ### `preResolveTypes` diff --git a/website/docs/generated-config/flow-resolvers.md b/website/docs/generated-config/flow-resolvers.md index f5ef1594350..1b86553c284 100644 --- a/website/docs/generated-config/flow-resolvers.md +++ b/website/docs/generated-config/flow-resolvers.md @@ -321,6 +321,14 @@ Defines the prefix value used for `__resolveType` and and `__isTypeOf` resolvers If you are using `mercurius-js`, please set this field to empty string for better compatiblity. +### `onlyResolveTypeForInterfaces` + +type: `boolean` +default: `false` + +Turning this flag to `true` will generate resolver siganture that has only `resolveType` for interfaces, forcing developers to write inherited type resolvers in the type itself. + + ### `scalars` type: `ScalarsMap` diff --git a/website/docs/generated-config/flow.md b/website/docs/generated-config/flow.md index 6e1b7d5c1b1..3d0c1caf083 100644 --- a/website/docs/generated-config/flow.md +++ b/website/docs/generated-config/flow.md @@ -1,5 +1,5 @@ -This plugin generates Flow types based on your `GraphQLSchema`. - +This plugin generates Flow types based on your `GraphQLSchema`. + It generates types for your entire schema: types, input types, enum, interface, scalar and union. ## Installation @@ -25,13 +25,13 @@ Generates Flow types as Exact types. #### Usage Examples -```yml -generates: - path/to/file.ts: - plugins: - - flow - config: - useFlowExactObjects: false +```yml +generates: + path/to/file.ts: + plugins: + - flow + config: + useFlowExactObjects: false ``` ### `useFlowReadOnlyTypes` @@ -43,13 +43,13 @@ Generates read-only Flow types #### Usage Examples -```yml -generates: - path/to/file.ts: - plugins: - - flow - config: - useFlowReadOnlyTypes: true +```yml +generates: + path/to/file.ts: + plugins: + - flow + config: + useFlowReadOnlyTypes: true ``` ### `addUnderscoreToArgsType` diff --git a/website/docs/generated-config/java-apollo-android.md b/website/docs/generated-config/java-apollo-android.md index 77564295d4f..d629daeb47d 100644 --- a/website/docs/generated-config/java-apollo-android.md +++ b/website/docs/generated-config/java-apollo-android.md @@ -22,14 +22,14 @@ Customize the Java package name for the generated operations. The default packag #### Usage Examples -```yml -generates: -./app/src/main/java/: - preset: java-apollo-android - config: - package: "com.my.package.generated.graphql" - plugins: - - java-apollo-android +```yml +generates: +./app/src/main/java/: + preset: java-apollo-android + config: + package: "com.my.package.generated.graphql" + plugins: + - java-apollo-android ``` ### `typePackage` @@ -40,14 +40,14 @@ Customize the Java package name for the types generated based on input types. #### Usage Examples -```yml -generates: -./app/src/main/java/: - preset: java-apollo-android - config: - typePackage: "com.my.package.generated.graphql" - plugins: - - java-apollo-android +```yml +generates: +./app/src/main/java/: + preset: java-apollo-android + config: + typePackage: "com.my.package.generated.graphql" + plugins: + - java-apollo-android ``` ### `fragmentPackage` @@ -58,14 +58,14 @@ Customize the Java package name for the fragments generated classes. #### Usage Examples -```yml -generates: -./app/src/main/java/: - preset: java-apollo-android - config: - fragmentPackage: "com.my.package.generated.graphql" - plugins: - - java-apollo-android +```yml +generates: +./app/src/main/java/: + preset: java-apollo-android + config: + fragmentPackage: "com.my.package.generated.graphql" + plugins: + - java-apollo-android ``` ### `fileType` diff --git a/website/docs/generated-config/java-resolvers.md b/website/docs/generated-config/java-resolvers.md index 39ae7b94f94..d6f240da7bb 100644 --- a/website/docs/generated-config/java-resolvers.md +++ b/website/docs/generated-config/java-resolvers.md @@ -20,33 +20,33 @@ Customize the Java package name. The default package name will be generated acco #### Usage Examples -```yml -generates: - src/main/java/my-org/my-app/Resolvers.java: - plugins: - - java-resolvers - config: - package: custom.package.name +```yml +generates: + src/main/java/my-org/my-app/Resolvers.java: + plugins: + - java-resolvers + config: + package: custom.package.name ``` ### `mappers` type: `object` -Allow you to replace specific GraphQL types with your custom model classes. This is useful when you want to make sure your resolvers returns the correct class. -The default value is the values set by `defaultMapper` configuration. +Allow you to replace specific GraphQL types with your custom model classes. This is useful when you want to make sure your resolvers returns the correct class. +The default value is the values set by `defaultMapper` configuration. You can use a direct path to the package, or use `package#class` syntax to have it imported. #### Usage Examples -```yml -generates: - src/main/java/my-org/my-app/Resolvers.java: - plugins: - - java-resolvers - config: - mappers: - User: com.app.models#UserObject +```yml +generates: + src/main/java/my-org/my-app/Resolvers.java: + plugins: + - java-resolvers + config: + mappers: + User: com.app.models#UserObject ``` ### `defaultMapper` @@ -54,19 +54,19 @@ generates: type: `string` default: `Object` -Sets the default mapper value in case it's not specified by `mappers`. -You can use a direct path to the package, or use `package#class` syntax to have it imported. +Sets the default mapper value in case it's not specified by `mappers`. +You can use a direct path to the package, or use `package#class` syntax to have it imported. The default mapper is Java's `Object`. #### Usage Examples -```yml -generates: - src/main/java/my-org/my-app/Resolvers.java: - plugins: - - java-resolvers - config: - defaultMapper: my.app.models.BaseEntity +```yml +generates: + src/main/java/my-org/my-app/Resolvers.java: + plugins: + - java-resolvers + config: + defaultMapper: my.app.models.BaseEntity ``` ### `className` @@ -78,13 +78,13 @@ Allow you to customize the parent class name. #### Usage Examples -```yml -generates: - src/main/java/my-org/my-app/Resolvers.java: - plugins: - - java-resolvers - config: - className: MyResolvers +```yml +generates: + src/main/java/my-org/my-app/Resolvers.java: + plugins: + - java-resolvers + config: + className: MyResolvers ``` ### `listType` @@ -96,13 +96,13 @@ Allow you to customize the list type. #### Usage Examples -```yml -generates: - src/main/java/my-org/my-app/Resolvers.java: - plugins: - - java-resolvers - config: - listType: Map +```yml +generates: + src/main/java/my-org/my-app/Resolvers.java: + plugins: + - java-resolvers + config: + listType: Map ``` ### `scalars` diff --git a/website/docs/generated-config/java.md b/website/docs/generated-config/java.md index ef14414bc08..0f0ec40960e 100644 --- a/website/docs/generated-config/java.md +++ b/website/docs/generated-config/java.md @@ -20,33 +20,33 @@ Customize the Java package name. The default package name will be generated acco #### Usage Examples -```yml -generates: - src/main/java/my-org/my-app/Resolvers.java: - plugins: - - java-resolvers - config: - package: custom.package.name +```yml +generates: + src/main/java/my-org/my-app/Resolvers.java: + plugins: + - java-resolvers + config: + package: custom.package.name ``` ### `mappers` type: `object` -Allow you to replace specific GraphQL types with your custom model classes. This is useful when you want to make sure your resolvers returns the correct class. -The default value is the values set by `defaultMapper` configuration. +Allow you to replace specific GraphQL types with your custom model classes. This is useful when you want to make sure your resolvers returns the correct class. +The default value is the values set by `defaultMapper` configuration. You can use a direct path to the package, or use `package#class` syntax to have it imported. #### Usage Examples -```yml -generates: - src/main/java/my-org/my-app/Resolvers.java: - plugins: - - java-resolvers - config: - mappers: - User: com.app.models#UserObject +```yml +generates: + src/main/java/my-org/my-app/Resolvers.java: + plugins: + - java-resolvers + config: + mappers: + User: com.app.models#UserObject ``` ### `defaultMapper` @@ -54,19 +54,19 @@ generates: type: `string` default: `Object` -Sets the default mapper value in case it's not specified by `mappers`. -You can use a direct path to the package, or use `package#class` syntax to have it imported. +Sets the default mapper value in case it's not specified by `mappers`. +You can use a direct path to the package, or use `package#class` syntax to have it imported. The default mapper is Java's `Object`. #### Usage Examples -```yml -generates: - src/main/java/my-org/my-app/Resolvers.java: - plugins: - - java-resolvers - config: - defaultMapper: my.app.models.BaseEntity +```yml +generates: + src/main/java/my-org/my-app/Resolvers.java: + plugins: + - java-resolvers + config: + defaultMapper: my.app.models.BaseEntity ``` ### `className` @@ -78,13 +78,13 @@ Allow you to customize the parent class name. #### Usage Examples -```yml -generates: - src/main/java/my-org/my-app/Resolvers.java: - plugins: - - java-resolvers - config: - className: MyResolvers +```yml +generates: + src/main/java/my-org/my-app/Resolvers.java: + plugins: + - java-resolvers + config: + className: MyResolvers ``` ### `listType` @@ -96,13 +96,13 @@ Allow you to customize the list type. #### Usage Examples -```yml -generates: - src/main/java/my-org/my-app/Resolvers.java: - plugins: - - java-resolvers - config: - listType: Map +```yml +generates: + src/main/java/my-org/my-app/Resolvers.java: + plugins: + - java-resolvers + config: + listType: Map ``` ### `scalars` diff --git a/website/docs/generated-config/kotlin.md b/website/docs/generated-config/kotlin.md index c50f600ecbb..40628cc63d5 100644 --- a/website/docs/generated-config/kotlin.md +++ b/website/docs/generated-config/kotlin.md @@ -20,13 +20,13 @@ Customize the Java package name. The default package name will be generated acco #### Usage Examples -```yml -generates: - src/main/kotlin/my-org/my-app/Resolvers.kt: - plugins: - - kotlin - config: - package: custom.package.name +```yml +generates: + src/main/kotlin/my-org/my-app/Resolvers.kt: + plugins: + - kotlin + config: + package: custom.package.name ``` ### `enumValues` @@ -45,13 +45,13 @@ Allow you to customize the list type #### Usage Examples -```yml -generates: - src/main/kotlin/my-org/my-app/Types.kt: - plugins: - - kotlin - config: - listType: Map +```yml +generates: + src/main/kotlin/my-org/my-app/Types.kt: + plugins: + - kotlin + config: + listType: Map ``` ### `withTypes` @@ -63,13 +63,13 @@ Allow you to enable generation for the types #### Usage Examples -```yml -generates: - src/main/kotlin/my-org/my-app/Types.kt: - plugins: - - kotlin - config: - withTypes: true +```yml +generates: + src/main/kotlin/my-org/my-app/Types.kt: + plugins: + - kotlin + config: + withTypes: true ``` ### `scalars` diff --git a/website/docs/generated-config/named-operations-object.md b/website/docs/generated-config/named-operations-object.md index 57d29cbf887..5664f96280e 100644 --- a/website/docs/generated-config/named-operations-object.md +++ b/website/docs/generated-config/named-operations-object.md @@ -29,4 +29,11 @@ path/to/file.ts: - named-operations-object config: identifierName: ListAllOperations -``` \ No newline at end of file +``` + +### `useConsts` + +type: `boolean` +default: `false` + +Will generate a const string instead of regular string. diff --git a/website/docs/generated-config/time.md b/website/docs/generated-config/time.md index 35d0c3bf407..d6edfd5bc6f 100644 --- a/website/docs/generated-config/time.md +++ b/website/docs/generated-config/time.md @@ -21,12 +21,12 @@ Customize the Moment format of the output time. #### Usage Examples -```yml -generates: -path/to/file.ts: - plugins: - - time: - format: DD.MM.YY +```yml +generates: +path/to/file.ts: + plugins: + - time: + format: DD.MM.YY ``` ### `message` @@ -38,10 +38,10 @@ Customize the comment message #### Usage Examples -```yml -generates: -path/to/file.ts: - plugins: - - time: - message: "The file generated on: " +```yml +generates: +path/to/file.ts: + plugins: + - time: + message: "The file generated on: " ``` \ No newline at end of file diff --git a/website/docs/generated-config/typescript-apollo-angular.md b/website/docs/generated-config/typescript-apollo-angular.md index 264a245efbd..60b38d79380 100644 --- a/website/docs/generated-config/typescript-apollo-angular.md +++ b/website/docs/generated-config/typescript-apollo-angular.md @@ -287,6 +287,8 @@ Declares how DocumentNode are created: - `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them. - `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom` +Note that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter. + ### `optimizeDocumentNode` diff --git a/website/docs/generated-config/typescript-compatibility.md b/website/docs/generated-config/typescript-compatibility.md index 0453e7523d1..3f728abba53 100644 --- a/website/docs/generated-config/typescript-compatibility.md +++ b/website/docs/generated-config/typescript-compatibility.md @@ -1,5 +1,5 @@ -If you are migrating from <1.0, we created a new plugin called `typescript-compatibility` that generates backward compatibility for the `typescript-operations` and `typescript-react-apollo` plugins. - +If you are migrating from <1.0, we created a new plugin called `typescript-compatibility` that generates backward compatibility for the `typescript-operations` and `typescript-react-apollo` plugins. + It generates types that are pointing to the new form of types. It supports _most_ of the use-cases. ## Installation @@ -25,15 +25,15 @@ Does not generate TypeScript `namespace`s and uses the operation name as prefix. #### Usage Examples -```yml -generates: -path/to/file.ts: - plugins: - - typescript - - typescript-operations - - typescript-compatibility - config: - noNamespaces: true +```yml +generates: +path/to/file.ts: + plugins: + - typescript + - typescript-operations + - typescript-compatibility + config: + noNamespaces: true ``` ### `strict` @@ -45,15 +45,15 @@ Make sure to generate code that compatible with TypeScript strict mode. #### Usage Examples -```yml -generates: -path/to/file.ts: - plugins: - - typescript - - typescript-operations - - typescript-compatibility - config: - strict: true +```yml +generates: +path/to/file.ts: + plugins: + - typescript + - typescript-operations + - typescript-compatibility + config: + strict: true ``` ### `preResolveTypes` diff --git a/website/docs/generated-config/typescript-document-nodes.md b/website/docs/generated-config/typescript-document-nodes.md index a28d9cec43f..7069ccb96a3 100644 --- a/website/docs/generated-config/typescript-document-nodes.md +++ b/website/docs/generated-config/typescript-document-nodes.md @@ -19,15 +19,15 @@ This plugin generates TypeScript source (`.ts`) file from GraphQL files (`.graph type: `NamingConvention` default: `change-case-all#pascalCase` -Allow you to override the naming convention of the output. -You can either override all namings, or specify an object with specific custom naming convention per output. -The format of the converter must be a valid `module#method`. -Allowed values for specific output are: `typeNames`, `enumValues`. -You can also use "keep" to keep all GraphQL names as-is. -Additionally you can set `transformUnderscore` to `true` if you want to override the default behavior, -which is to preserves underscores. - -Available case functions in `change-case-all` are `camelCase`, `capitalCase`, `constantCase`, `dotCase`, `headerCase`, `noCase`, `paramCase`, `pascalCase`, `pathCase`, `sentenceCase`, `snakeCase`, `lowerCase`, `localeLowerCase`, `lowerCaseFirst`, `spongeCase`, `titleCase`, `upperCase`, `localeUpperCase` and `upperCaseFirst` +Allow you to override the naming convention of the output. +You can either override all namings, or specify an object with specific custom naming convention per output. +The format of the converter must be a valid `module#method`. +Allowed values for specific output are: `typeNames`, `enumValues`. +You can also use "keep" to keep all GraphQL names as-is. +Additionally you can set `transformUnderscore` to `true` if you want to override the default behavior, +which is to preserves underscores. + +Available case functions in `change-case-all` are `camelCase`, `capitalCase`, `constantCase`, `dotCase`, `headerCase`, `noCase`, `paramCase`, `pascalCase`, `pathCase`, `sentenceCase`, `snakeCase`, `lowerCase`, `localeLowerCase`, `lowerCaseFirst`, `spongeCase`, `titleCase`, `upperCase`, `localeUpperCase` and `upperCaseFirst` [See more](https://github.com/btxtiger/change-case-all) @@ -40,14 +40,14 @@ Adds prefix to the name #### Usage Examples -```yml - documents: src/api/user-service/queries.graphql - generates: - src/api/user-service/queries.ts: - plugins: - - typescript-document-nodes - config: - namePrefix: 'gql' +```yml + documents: src/api/user-service/queries.graphql + generates: + src/api/user-service/queries.ts: + plugins: + - typescript-document-nodes + config: + namePrefix: 'gql' ``` ### `nameSuffix` @@ -59,14 +59,14 @@ Adds suffix to the name #### Usage Examples -```yml - documents: src/api/user-service/queries.graphql - generates: - src/api/user-service/queries.ts: - plugins: - - typescript-document-nodes - config: - nameSuffix: 'Query' +```yml + documents: src/api/user-service/queries.graphql + generates: + src/api/user-service/queries.ts: + plugins: + - typescript-document-nodes + config: + nameSuffix: 'Query' ``` ### `fragmentPrefix` @@ -199,6 +199,8 @@ Declares how DocumentNode are created: - `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them. - `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom` +Note that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter. + ### `optimizeDocumentNode` diff --git a/website/docs/generated-config/typescript-generic-sdk.md b/website/docs/generated-config/typescript-generic-sdk.md new file mode 100644 index 00000000000..ff6b211472f --- /dev/null +++ b/website/docs/generated-config/typescript-generic-sdk.md @@ -0,0 +1,287 @@ +This plugin generate a generic SDK (without any Requester implemented), allow you to easily customize the way you fetch your data, without loosing the strongly-typed integration. + +## Installation + + + +typescript-generic-sdk plugin version + + + +:::shell Using `yarn` + yarn add -D @graphql-codegen/typescript-generic-sdk +::: + +## API Reference + +### `usingObservableFrom` + +type: `string` + +usingObservableFrom: "import Observable from 'zen-observable';" +OR +usingObservableFrom: "import { Observable } from 'rxjs';" + + +### `noGraphQLTag` + +type: `boolean` +default: `false` + +Deprecated. Changes the documentMode to `documentNode`. + + +### `gqlImport` + +type: `string` +default: `graphql-tag#gql` + +Customize from which module will `gql` be imported from. +This is useful if you want to use modules other than `graphql-tag`, e.g. `graphql.macro`. + +#### Usage Examples + +##### graphql.macro +```yml +config: + gqlImport: graphql.macro#gql +``` + +##### Gatsby +```yml +config: + gqlImport: gatsby#graphql +``` + +### `documentNodeImport` + +type: `string` +default: `graphql#DocumentNode` + +Customize from which module will `DocumentNode` be imported from. +This is useful if you want to use modules other than `graphql`, e.g. `@graphql-typed-document-node`. + + +### `noExport` + +type: `boolean` +default: `false` + +Set this configuration to `true` if you wish to tell codegen to generate code with no `export` identifier. + + +### `dedupeOperationSuffix` + +type: `boolean` +default: `false` + +Set this configuration to `true` if you wish to make sure to remove duplicate operation name suffix. + + +### `omitOperationSuffix` + +type: `boolean` +default: `false` + +Set this configuration to `true` if you wish to disable auto add suffix of operation name, like `Query`, `Mutation`, `Subscription`, `Fragment`. + + +### `operationResultSuffix` + +type: `string` +default: `` + +Adds a suffix to generated operation result type names + + +### `documentVariablePrefix` + +type: `string` +default: `` + +Changes the GraphQL operations variables prefix. + + +### `documentVariableSuffix` + +type: `string` +default: `Document` + +Changes the GraphQL operations variables suffix. + + +### `fragmentVariablePrefix` + +type: `string` +default: `` + +Changes the GraphQL fragments variables prefix. + + +### `fragmentVariableSuffix` + +type: `string` +default: `FragmentDoc` + +Changes the GraphQL fragments variables suffix. + + +### `documentMode` + +type: `DocumentMode` +default: `graphQLTag` + +Declares how DocumentNode are created: +- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client +- `documentNode`: document nodes will be generated as objects when we generate the templates. +- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them. +- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom` + +Note that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter. + + +### `optimizeDocumentNode` + +type: `boolean` +default: `true` + +If you are using `documentNode: documentMode | documentNodeImportFragments`, you can set this to `true` to apply document optimizations for your GraphQL document. +This will remove all "loc" and "description" fields from the compiled document, and will remove all empty arrays (such as `directives`, `arguments` and `variableDefinitions`). + + +### `importOperationTypesFrom` + +type: `string` +default: `` + +This config is used internally by presets, but you can use it manually to tell codegen to prefix all base types that it's using. +This is useful if you wish to generate base types from `typescript-operations` plugin into a different file, and import it from there. + + +### `importDocumentNodeExternallyFrom` + +type: `string` +default: `` + +This config should be used if `documentMode` is `external`. This has 2 usage: +- any string: This would be the path to import document nodes from. This can be used if we want to manually create the document nodes e.g. Use `graphql-tag` in a separate file and export the generated document +- 'near-operation-file': This is a special mode that is intended to be used with `near-operation-file` preset to import document nodes from those files. If these files are `.graphql` files, we make use of webpack loader. + +#### Usage Examples + +```yml +config: + documentMode: external + importDocumentNodeExternallyFrom: path/to/document-node-file +``` + +```yml +config: + documentMode: external + importDocumentNodeExternallyFrom: near-operation-file +``` + +### `pureMagicComment` + +type: `boolean` +default: `false` + +This config adds PURE magic comment to the static variables to enforce treeshaking for your bundler. + + +### `experimentalFragmentVariables` + +type: `boolean` +default: `false` + +If set to true, it will enable support for parsing variables on fragments. + + +### `scalars` + +type: `ScalarsMap` + +Extends or overrides the built-in scalars and custom GraphQL scalars to a custom type. + + +### `namingConvention` + +type: `NamingConvention` +default: `change-case-all#pascalCase` + +Allow you to override the naming convention of the output. +You can either override all namings, or specify an object with specific custom naming convention per output. +The format of the converter must be a valid `module#method`. +Allowed values for specific output are: `typeNames`, `enumValues`. +You can also use "keep" to keep all GraphQL names as-is. +Additionally you can set `transformUnderscore` to `true` if you want to override the default behavior, +which is to preserves underscores. + +Available case functions in `change-case-all` are `camelCase`, `capitalCase`, `constantCase`, `dotCase`, `headerCase`, `noCase`, `paramCase`, `pascalCase`, `pathCase`, `sentenceCase`, `snakeCase`, `lowerCase`, `localeLowerCase`, `lowerCaseFirst`, `spongeCase`, `titleCase`, `upperCase`, `localeUpperCase` and `upperCaseFirst` +[See more](https://github.com/btxtiger/change-case-all) + + +### `typesPrefix` + +type: `string` +default: `` + +Prefixes all the generated types. + +#### Usage Examples + +```yml +config: + typesPrefix: I +``` + +### `typesSuffix` + +type: `string` +default: `` + +Suffixes all the generated types. + +#### Usage Examples + +```yml +config: + typesSuffix: I +``` + +### `skipTypename` + +type: `boolean` +default: `false` + +Does not add __typename to the generated types, unless it was specified in the selection set. + +#### Usage Examples + +```yml +config: + skipTypename: true +``` + +### `nonOptionalTypename` + +type: `boolean` +default: `false` + +Automatically adds `__typename` field to the generated types, even when they are not specified +in the selection set, and makes it non-optional + +#### Usage Examples + +```yml +config: + nonOptionalTypename: true +``` + +### `useTypeImports` + +type: `boolean` +default: `false` + +Will use `import type {}` rather than `import {}` when importing only types. This gives +compatibility with TypeScript's "importsNotUsedAsValues": "error" option diff --git a/website/docs/generated-config/typescript-graphql-request.md b/website/docs/generated-config/typescript-graphql-request.md index e8867b36beb..427a736c647 100644 --- a/website/docs/generated-config/typescript-graphql-request.md +++ b/website/docs/generated-config/typescript-graphql-request.md @@ -23,15 +23,15 @@ By default the `request` method return the `data` or `errors` key from the respo #### Usage Examples -```yml -generates: -path/to/file.ts: - plugins: - - typescript - - typescript-operations - - typescript-graphql-request - config: - rawRequest: true +```yml +generates: +path/to/file.ts: + plugins: + - typescript + - typescript-operations + - typescript-graphql-request + config: + rawRequest: true ``` ### `noGraphQLTag` @@ -148,6 +148,8 @@ Declares how DocumentNode are created: - `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them. - `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom` +Note that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter. + ### `optimizeDocumentNode` diff --git a/website/docs/generated-config/typescript-mongodb.md b/website/docs/generated-config/typescript-mongodb.md index e2d40f36352..60b0c2ed9f6 100644 --- a/website/docs/generated-config/typescript-mongodb.md +++ b/website/docs/generated-config/typescript-mongodb.md @@ -21,9 +21,9 @@ Customize the suffix for the generated GraphQL `type`s. #### Usage Examples -```yml -config: - dbTypeSuffix: MyType +```yml +config: + dbTypeSuffix: MyType ``` ### `dbInterfaceSuffix` @@ -35,9 +35,9 @@ Customize the suffix for the generated GraphQL `interface`s. #### Usage Examples -```yml -config: - dbInterfaceSuffix: MyInterface +```yml +config: + dbInterfaceSuffix: MyInterface ``` ### `objectIdType` @@ -49,9 +49,9 @@ Customize the type of `_id` fields. You can either specify a type name, or speci #### Usage Examples -```yml -config: - objectIdType: ./my-models.ts#MyIdType +```yml +config: + objectIdType: ./my-models.ts#MyIdType ``` ### `idFieldName` @@ -63,9 +63,9 @@ Customize the name of the id field generated after using `@id` directive over a #### Usage Examples -```yml -config: - idFieldName: id +```yml +config: + idFieldName: id ``` ### `enumsAsString` @@ -77,9 +77,9 @@ Replaces generated `enum` values with `string`. #### Usage Examples -```yml -config: - enumsAsString: false +```yml +config: + enumsAsString: false ``` ### `avoidOptionals` @@ -87,20 +87,20 @@ config: type: `boolean` default: `false` -This will cause the generator to avoid using TypeScript optionals (`?`), -so the following definition: `type A { myField: String }` will output `myField: Maybe` +This will cause the generator to avoid using TypeScript optionals (`?`), +so the following definition: `type A { myField: String }` will output `myField: Maybe` instead of `myField?: Maybe`. #### Usage Examples -```yml -generates: -path/to/file.ts: - plugins: - - typescript - - typescript-mongodb - config: - avoidOptionals: true +```yml +generates: +path/to/file.ts: + plugins: + - typescript + - typescript-mongodb + config: + avoidOptionals: true ``` ### `scalars` diff --git a/website/docs/generated-config/typescript-react-apollo.md b/website/docs/generated-config/typescript-react-apollo.md index 1b44083ed74..806777458c9 100644 --- a/website/docs/generated-config/typescript-react-apollo.md +++ b/website/docs/generated-config/typescript-react-apollo.md @@ -359,6 +359,8 @@ Declares how DocumentNode are created: - `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them. - `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom` +Note that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter. + ### `optimizeDocumentNode` diff --git a/website/docs/generated-config/typescript-resolvers.md b/website/docs/generated-config/typescript-resolvers.md index d5fdf3b4849..6ae2941b1ed 100644 --- a/website/docs/generated-config/typescript-resolvers.md +++ b/website/docs/generated-config/typescript-resolvers.md @@ -1,6 +1,6 @@ -This plugin generates TypeScript signature for `resolve` functions of your GraphQL API. -You can use this plugin a to generate simple resolvers signature based on your GraphQL types, or you can change it's behavior be providing custom model types (mappers). - +This plugin generates TypeScript signature for `resolve` functions of your GraphQL API. +You can use this plugin a to generate simple resolvers signature based on your GraphQL types, or you can change it's behavior be providing custom model types (mappers). + You can find a blog post explaining the usage of this plugin here: https://the-guild.dev/blog/better-type-safety-for-resolvers-with-graphql-codegen ## Installation @@ -26,14 +26,14 @@ Adds an index signature to any generates resolver. #### Usage Examples -```yml -generates: -path/to/file.ts: - plugins: - - typescript - - typescript-resolvers - config: - useIndexSignature: true +```yml +generates: +path/to/file.ts: + plugins: + - typescript + - typescript-resolvers + config: + useIndexSignature: true ``` ### `noSchemaStitching` @@ -41,20 +41,20 @@ path/to/file.ts: type: `boolean` default: `false` -Disables Schema Stitching support. - +Disables Schema Stitching support. + Note: The default behavior will be reversed in the next major release. Support for Schema Stitching will be disabled by default. #### Usage Examples -```yml -generates: -path/to/file.ts: - plugins: - - typescript - - typescript-resolvers - config: - noSchemaStitching: true +```yml +generates: +path/to/file.ts: + plugins: + - typescript + - typescript-resolvers + config: + noSchemaStitching: true ``` ### `wrapFieldDefinitions` @@ -62,8 +62,8 @@ path/to/file.ts: type: `boolean` default: `true` -Set to `true` in order to wrap field definitions with `FieldWrapper`. -This is useful to allow return types such as Promises and functions. Needed for +Set to `true` in order to wrap field definitions with `FieldWrapper`. +This is useful to allow return types such as Promises and functions. Needed for compatibility with `federation: true` when @@ -76,14 +76,14 @@ You can provide your custom GraphQLResolveInfo instead of the default one from g #### Usage Examples -```yml -generates: -path/to/file.ts: - plugins: - - typescript - - typescript-resolvers - config: - customResolveInfo: ./my-types#MyResolveInfo +```yml +generates: +path/to/file.ts: + plugins: + - typescript + - typescript-resolvers + config: + customResolveInfo: ./my-types#MyResolveInfo ``` ### `customResolverFn` @@ -95,49 +95,49 @@ You can provide your custom ResolveFn instead the default. It has to be a type t #### Usage Examples -##### Custom Signature -```yml -generates: -path/to/file.ts: - plugins: - - typescript - - typescript-resolvers - config: - customResolverFn: ./my-types#MyResolveFn -``` - -##### With Graphile -```yml -generates: -path/to/file.ts: - plugins: - - add: - content: "import { GraphileHelpers } from 'graphile-utils/node8plus/fieldHelpers';" - - typescript - - typescript-resolvers - config: - customResolverFn: | - ( - parent: TParent, - args: TArgs, - context: TContext, - info: GraphQLResolveInfo & { graphile: GraphileHelpers } - ) => Promise | TResult; +##### Custom Signature +```yml +generates: +path/to/file.ts: + plugins: + - typescript + - typescript-resolvers + config: + customResolverFn: ./my-types#MyResolveFn +``` + +##### With Graphile +```yml +generates: +path/to/file.ts: + plugins: + - add: + content: "import { GraphileHelpers } from 'graphile-utils/node8plus/fieldHelpers';" + - typescript + - typescript-resolvers + config: + customResolverFn: | + ( + parent: TParent, + args: TArgs, + context: TContext, + info: GraphQLResolveInfo & { graphile: GraphileHelpers } + ) => Promise | TResult; ``` ### `allowParentTypeOverride` type: `boolean` -Allow you to override the `ParentType` generic in each resolver, by avoid enforcing the base type of the generated generic type. - +Allow you to override the `ParentType` generic in each resolver, by avoid enforcing the base type of the generated generic type. + This will generate `ParentType = Type` instead of `ParentType extends Type = Type` in each resolver. #### Usage Examples -```yml - config: - allowParentTypeOverride: true +```yml + config: + allowParentTypeOverride: true ``` ### `optionalInfoArgument` @@ -148,9 +148,9 @@ Sets `info` argument of resolver function to be optional field. Useful for testi #### Usage Examples -```yml - config: - optionalInfoArgument: true +```yml + config: + optionalInfoArgument: true ``` ### `addUnderscoreToArgsType` @@ -456,6 +456,14 @@ Defines the prefix value used for `__resolveType` and and `__isTypeOf` resolvers If you are using `mercurius-js`, please set this field to empty string for better compatiblity. +### `onlyResolveTypeForInterfaces` + +type: `boolean` +default: `false` + +Turning this flag to `true` will generate resolver siganture that has only `resolveType` for interfaces, forcing developers to write inherited type resolvers in the type itself. + + ### `scalars` type: `ScalarsMap` diff --git a/website/docs/generated-config/typescript-stencil-apollo.md b/website/docs/generated-config/typescript-stencil-apollo.md index 272faf151d1..ff03cbbe542 100644 --- a/website/docs/generated-config/typescript-stencil-apollo.md +++ b/website/docs/generated-config/typescript-stencil-apollo.md @@ -1,5 +1,5 @@ -This plugin generates Stencil Apollo functional components typings - +This plugin generates Stencil Apollo functional components typings + It extends the basic TypeScript plugins: `@graphql-codegen/typescript`, `@graphql-codegen/typescript-operations` - and thus shares a similar configuration. ## Installation @@ -138,6 +138,8 @@ Declares how DocumentNode are created: - `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them. - `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom` +Note that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter. + ### `optimizeDocumentNode` diff --git a/website/docs/generated-config/typescript-urql.md b/website/docs/generated-config/typescript-urql.md index c7be7f78444..2f94e620f15 100644 --- a/website/docs/generated-config/typescript-urql.md +++ b/website/docs/generated-config/typescript-urql.md @@ -35,8 +35,8 @@ Customized the output by enabling/disabling the generated React Hooks. type: `string` default: `urql` -You can specify module that exports components `Query`, `Mutation`, `Subscription` and HOCs -This is useful for further abstraction of some common tasks (eg. error handling). +You can specify module that exports components `Query`, `Mutation`, `Subscription` and HOCs +This is useful for further abstraction of some common tasks (eg. error handling). Filepath relative to generated file can be also specified. @@ -154,6 +154,8 @@ Declares how DocumentNode are created: - `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them. - `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom` +Note that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter. + ### `optimizeDocumentNode` diff --git a/website/docs/generated-config/typescript-vue-apollo.md b/website/docs/generated-config/typescript-vue-apollo.md index 276ce4689cf..ab1fb8f8f2d 100644 --- a/website/docs/generated-config/typescript-vue-apollo.md +++ b/website/docs/generated-config/typescript-vue-apollo.md @@ -207,6 +207,8 @@ Declares how DocumentNode are created: - `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them. - `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom` +Note that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter. + ### `optimizeDocumentNode` diff --git a/website/docs/plugins/index.md b/website/docs/plugins/index.md index 46175ed0b16..0e86b28792f 100644 --- a/website/docs/plugins/index.md +++ b/website/docs/plugins/index.md @@ -22,6 +22,7 @@ Below is a table that lists all available plugins which can be installed via NPM | `typescript-vue-apollo` | Generate TypeScript types, and Vue Apollo composition functions | [`@graphql-codegen/typescript-vue-apollo`](./typescript-vue-apollo.md) | | `typescript-urql` | Generate TypeScript types, and Urql Components | [`@graphql-codegen/typescript-urql`](./typescript-urql.md) | | `typescript-graphql-request` | Generates fully-typed ready-to-use SDK for graphql-request | [`@graphql-codegen/typescript-graphql-request`](./typescript-graphql-request.md) | +| `typescript-generic-sdk` | Generates fully-typed generic SDK you can hook into any client. | [`@graphql-codegen/typescript-generic-sdk`](./typescript-generic-sdk.md) | | `typescript-stencil-apollo` | Generate TypeScript types, and Stencil Apollo Components | [`@graphql-codegen/typescript-stencil-apollo`](./typescript-stencil-apollo.md) | | `typescript-mongodb` | Generate server-side TypeScript types, with MongoDB models | [`@graphql-codegen/typescript-mongodb`](./typescript-mongodb.md) | | `typescript-graphql-files-modules` | Generate `declare module` for `.graphql` files | [`@graphql-codegen/typescript-graphql-files-modules`](./typescript-graphql-files-modules.md) | diff --git a/website/docs/plugins/typescript-generic-sdk.md b/website/docs/plugins/typescript-generic-sdk.md new file mode 100644 index 00000000000..2264a197d22 --- /dev/null +++ b/website/docs/plugins/typescript-generic-sdk.md @@ -0,0 +1,15 @@ +--- +id: typescript-generic-sdk +title: TypeScript Generic SDK +--- + +{@import ../plugins/client-note.md} + +> Make sure you have `typescript` plugin and `typescript-operations` as well in your configuration: + +{@import ../generated-config/typescript-generic-sdk.md} + +## Usage + +You can find a usage [example for Apollo-Client here](https://gist.github.com/akozhemiakin/731b0c1e99eb89b01f80f08f9146b6b6). + diff --git a/website/sidebars.js b/website/sidebars.js index d55a5749a3c..05f2d68a4bb 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -31,6 +31,7 @@ module.exports = { 'plugins/typed-document-node', 'plugins/typescript-apollo-client-helpers', 'plugins/typescript-graphql-request', + 'plugins/typescript-generic-sdk', 'plugins/typescript-react-query', 'plugins/typescript-react-apollo', 'plugins/typescript-vue-apollo', diff --git a/website/static/config.schema.json b/website/static/config.schema.json index e15664a08d8..c58ba5fe09c 100644 --- a/website/static/config.schema.json +++ b/website/static/config.schema.json @@ -212,6 +212,112 @@ } } }, + "RawGenericSdkPluginConfig": { + "description": "This plugin generate a generic SDK (without any Requester implemented), allow you to easily customize the way you fetch your data, without loosing the strongly-typed integration.", + "type": "object", + "properties": { + "usingObservableFrom": { + "description": "usingObservableFrom: \"import Observable from 'zen-observable';\"\nOR\nusingObservableFrom: \"import { Observable } from 'rxjs';\"", + "type": "string" + }, + "noGraphQLTag": { + "description": "Deprecated. Changes the documentMode to `documentNode`.\nDefault value: \"false\"", + "type": "boolean" + }, + "gqlImport": { + "description": "Customize from which module will `gql` be imported from.\nThis is useful if you want to use modules other than `graphql-tag`, e.g. `graphql.macro`.\nDefault value: \"graphql-tag#gql\"", + "type": "string" + }, + "documentNodeImport": { + "description": "Customize from which module will `DocumentNode` be imported from.\nThis is useful if you want to use modules other than `graphql`, e.g. `@graphql-typed-document-node`.\nDefault value: \"graphql#DocumentNode\"", + "type": "string" + }, + "noExport": { + "description": "Set this configuration to `true` if you wish to tell codegen to generate code with no `export` identifier.\nDefault value: \"false\"", + "type": "boolean" + }, + "dedupeOperationSuffix": { + "description": "Set this configuration to `true` if you wish to make sure to remove duplicate operation name suffix.\nDefault value: \"false\"", + "type": "boolean" + }, + "omitOperationSuffix": { + "description": "Set this configuration to `true` if you wish to disable auto add suffix of operation name, like `Query`, `Mutation`, `Subscription`, `Fragment`.\nDefault value: \"false\"", + "type": "boolean" + }, + "operationResultSuffix": { + "description": "Adds a suffix to generated operation result type names\nDefault value: \"\"", + "type": "string" + }, + "documentVariablePrefix": { + "description": "Changes the GraphQL operations variables prefix.\nDefault value: \"\"", + "type": "string" + }, + "documentVariableSuffix": { + "description": "Changes the GraphQL operations variables suffix.\nDefault value: \"Document\"", + "type": "string" + }, + "fragmentVariablePrefix": { + "description": "Changes the GraphQL fragments variables prefix.\nDefault value: \"\"", + "type": "string" + }, + "fragmentVariableSuffix": { + "description": "Changes the GraphQL fragments variables suffix.\nDefault value: \"FragmentDoc\"", + "type": "string" + }, + "documentMode": { + "$ref": "#/definitions/DocumentMode", + "description": "Declares how DocumentNode are created:\n- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client\n- `documentNode`: document nodes will be generated as objects when we generate the templates.\n- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them.\n- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom`\n\nNote that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter.\nDefault value: \"graphQLTag\"" + }, + "optimizeDocumentNode": { + "description": "If you are using `documentNode: documentMode | documentNodeImportFragments`, you can set this to `true` to apply document optimizations for your GraphQL document.\nThis will remove all \"loc\" and \"description\" fields from the compiled document, and will remove all empty arrays (such as `directives`, `arguments` and `variableDefinitions`).\nDefault value: \"true\"", + "type": "boolean" + }, + "importOperationTypesFrom": { + "description": "This config is used internally by presets, but you can use it manually to tell codegen to prefix all base types that it's using.\nThis is useful if you wish to generate base types from `typescript-operations` plugin into a different file, and import it from there.\nDefault value: \"\"", + "type": "string" + }, + "importDocumentNodeExternallyFrom": { + "description": "This config should be used if `documentMode` is `external`. This has 2 usage:\n- any string: This would be the path to import document nodes from. This can be used if we want to manually create the document nodes e.g. Use `graphql-tag` in a separate file and export the generated document\n- 'near-operation-file': This is a special mode that is intended to be used with `near-operation-file` preset to import document nodes from those files. If these files are `.graphql` files, we make use of webpack loader.\nDefault value: \"\"", + "type": "string" + }, + "pureMagicComment": { + "description": "This config adds PURE magic comment to the static variables to enforce treeshaking for your bundler.\nDefault value: \"false\"", + "type": "boolean" + }, + "experimentalFragmentVariables": { + "description": "If set to true, it will enable support for parsing variables on fragments.\nDefault value: \"false\"", + "type": "boolean" + }, + "scalars": { + "$ref": "#/definitions/ScalarsMap", + "description": "Extends or overrides the built-in scalars and custom GraphQL scalars to a custom type." + }, + "namingConvention": { + "$ref": "#/definitions/NamingConvention", + "description": "Allow you to override the naming convention of the output.\nYou can either override all namings, or specify an object with specific custom naming convention per output.\nThe format of the converter must be a valid `module#method`.\nAllowed values for specific output are: `typeNames`, `enumValues`.\nYou can also use \"keep\" to keep all GraphQL names as-is.\nAdditionally you can set `transformUnderscore` to `true` if you want to override the default behavior,\nwhich is to preserves underscores.\n\nAvailable case functions in `change-case-all` are `camelCase`, `capitalCase`, `constantCase`, `dotCase`, `headerCase`, `noCase`, `paramCase`, `pascalCase`, `pathCase`, `sentenceCase`, `snakeCase`, `lowerCase`, `localeLowerCase`, `lowerCaseFirst`, `spongeCase`, `titleCase`, `upperCase`, `localeUpperCase` and `upperCaseFirst`\n[See more](https://github.com/btxtiger/change-case-all)\nDefault value: \"change-case-all#pascalCase\"" + }, + "typesPrefix": { + "description": "Prefixes all the generated types.\nDefault value: \"\"", + "type": "string" + }, + "typesSuffix": { + "description": "Suffixes all the generated types.\nDefault value: \"\"", + "type": "string" + }, + "skipTypename": { + "description": "Does not add __typename to the generated types, unless it was specified in the selection set.\nDefault value: \"false\"", + "type": "boolean" + }, + "nonOptionalTypename": { + "description": "Automatically adds `__typename` field to the generated types, even when they are not specified\nin the selection set, and makes it non-optional\nDefault value: \"false\"", + "type": "boolean" + }, + "useTypeImports": { + "type": "boolean", + "description": "Will use `import type {}` rather than `import {}` when importing only types. This gives\ncompatibility with TypeScript's \"importsNotUsedAsValues\": \"error\" option\nDefault value: \"false\"" + } + } + }, "ApolloClientHelpersConfig": { "type": "object", "properties": { @@ -239,7 +345,7 @@ }, "content": { "$ref": "#/definitions/Types.RequireExtension", - "description": "The actual content you wish to add, either a string or array of strings.\r\nYou can also specify a path to a local file and the content if it will be loaded by codegen." + "description": "The actual content you wish to add, either a string or array of strings.\nYou can also specify a path to a local file and the content if it will be loaded by codegen." } } }, @@ -645,7 +751,7 @@ }, "documentMode": { "$ref": "#/definitions/DocumentMode", - "description": "Declares how DocumentNode are created:\n- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client\n- `documentNode`: document nodes will be generated as objects when we generate the templates.\n- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them.\n- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom`\nDefault value: \"graphQLTag\"" + "description": "Declares how DocumentNode are created:\n- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client\n- `documentNode`: document nodes will be generated as objects when we generate the templates.\n- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them.\n- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom`\n\nNote that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter.\nDefault value: \"graphQLTag\"" }, "optimizeDocumentNode": { "description": "If you are using `documentNode: documentMode | documentNodeImportFragments`, you can set this to `true` to apply document optimizations for your GraphQL document.\nThis will remove all \"loc\" and \"description\" fields from the compiled document, and will remove all empty arrays (such as `directives`, `arguments` and `variableDefinitions`).\nDefault value: \"true\"", @@ -883,6 +989,10 @@ "identifierName": { "description": "Allow you to customize the name of the exported identifier\nDefault value: \"namedOperations\"", "type": "string" + }, + "useConsts": { + "description": "Will generate a const string instead of regular string.\nDefault value: \"false\"", + "type": "boolean" } } }, @@ -940,7 +1050,7 @@ }, "documentMode": { "$ref": "#/definitions/DocumentMode", - "description": "Declares how DocumentNode are created:\n- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client\n- `documentNode`: document nodes will be generated as objects when we generate the templates.\n- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them.\n- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom`\nDefault value: \"graphQLTag\"" + "description": "Declares how DocumentNode are created:\n- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client\n- `documentNode`: document nodes will be generated as objects when we generate the templates.\n- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them.\n- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom`\n\nNote that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter.\nDefault value: \"graphQLTag\"" }, "optimizeDocumentNode": { "description": "If you are using `documentNode: documentMode | documentNodeImportFragments`, you can set this to `true` to apply document optimizations for your GraphQL document.\nThis will remove all \"loc\" and \"description\" fields from the compiled document, and will remove all empty arrays (such as `directives`, `arguments` and `variableDefinitions`).\nDefault value: \"true\"", @@ -993,7 +1103,7 @@ } }, "CompatibilityPluginRawConfig": { - "description": "If you are migrating from <1.0, we created a new plugin called `typescript-compatibility` that generates backward compatibility for the `typescript-operations` and `typescript-react-apollo` plugins.\r\n\r\nIt generates types that are pointing to the new form of types. It supports _most_ of the use-cases.", + "description": "If you are migrating from <1.0, we created a new plugin called `typescript-compatibility` that generates backward compatibility for the `typescript-operations` and `typescript-react-apollo` plugins.\n\nIt generates types that are pointing to the new form of types. It supports _most_ of the use-cases.", "type": "object", "properties": { "noNamespaces": { @@ -1062,7 +1172,7 @@ "type": "boolean" }, "avoidOptionals": { - "description": "This will cause the generator to avoid using TypeScript optionals (`?`),\r\nso the following definition: `type A { myField: String }` will output `myField: Maybe`\r\ninstead of `myField?: Maybe`.\nDefault value: \"false\"", + "description": "This will cause the generator to avoid using TypeScript optionals (`?`),\nso the following definition: `type A { myField: String }` will output `myField: Maybe`\ninstead of `myField?: Maybe`.\nDefault value: \"false\"", "type": "boolean" }, "scalars": { @@ -1096,7 +1206,7 @@ } }, "TypeScriptResolversPluginConfig": { - "description": "This plugin generates TypeScript signature for `resolve` functions of your GraphQL API.\r\nYou can use this plugin a to generate simple resolvers signature based on your GraphQL types, or you can change it's behavior be providing custom model types (mappers).\r\n\r\nYou can find a blog post explaining the usage of this plugin here: https://the-guild.dev/blog/better-type-safety-for-resolvers-with-graphql-codegen", + "description": "This plugin generates TypeScript signature for `resolve` functions of your GraphQL API.\nYou can use this plugin a to generate simple resolvers signature based on your GraphQL types, or you can change it's behavior be providing custom model types (mappers).\n\nYou can find a blog post explaining the usage of this plugin here: https://the-guild.dev/blog/better-type-safety-for-resolvers-with-graphql-codegen", "type": "object", "properties": { "useIndexSignature": { @@ -1104,11 +1214,11 @@ "type": "boolean" }, "noSchemaStitching": { - "description": "Disables Schema Stitching support.\r\n\r\nNote: The default behavior will be reversed in the next major release. Support for Schema Stitching will be disabled by default.\nDefault value: \"false\"", + "description": "Disables Schema Stitching support.\n\nNote: The default behavior will be reversed in the next major release. Support for Schema Stitching will be disabled by default.\nDefault value: \"false\"", "type": "boolean" }, "wrapFieldDefinitions": { - "description": "Set to `true` in order to wrap field definitions with `FieldWrapper`.\r\nThis is useful to allow return types such as Promises and functions. Needed for\r\ncompatibility with `federation: true` when\nDefault value: \"true\"", + "description": "Set to `true` in order to wrap field definitions with `FieldWrapper`.\nThis is useful to allow return types such as Promises and functions. Needed for\ncompatibility with `federation: true` when\nDefault value: \"true\"", "type": "boolean" }, "customResolveInfo": { @@ -1120,7 +1230,7 @@ "type": "string" }, "allowParentTypeOverride": { - "description": "Allow you to override the `ParentType` generic in each resolver, by avoid enforcing the base type of the generated generic type.\r\n\r\nThis will generate `ParentType = Type` instead of `ParentType extends Type = Type` in each resolver.", + "description": "Allow you to override the `ParentType` generic in each resolver, by avoid enforcing the base type of the generated generic type.\n\nThis will generate `ParentType = Type` instead of `ParentType extends Type = Type` in each resolver.", "type": "boolean" }, "optionalInfoArgument": { @@ -1213,6 +1323,10 @@ "type": "string", "description": "Defines the prefix value used for `__resolveType` and and `__isTypeOf` resolvers.\nIf you are using `mercurius-js`, please set this field to empty string for better compatiblity.\nDefault value: \"'__'\"" }, + "onlyResolveTypeForInterfaces": { + "type": "boolean", + "description": "Turning this flag to `true` will generate resolver siganture that has only `resolveType` for interfaces, forcing developers to write inherited type resolvers in the type itself.\nDefault value: \"false\"" + }, "scalars": { "$ref": "#/definitions/ScalarsMap", "description": "Extends or overrides the built-in scalars and custom GraphQL scalars to a custom type." @@ -1344,7 +1458,7 @@ }, "documentMode": { "$ref": "#/definitions/DocumentMode", - "description": "Declares how DocumentNode are created:\n- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client\n- `documentNode`: document nodes will be generated as objects when we generate the templates.\n- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them.\n- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom`\nDefault value: \"graphQLTag\"" + "description": "Declares how DocumentNode are created:\n- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client\n- `documentNode`: document nodes will be generated as objects when we generate the templates.\n- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them.\n- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom`\n\nNote that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter.\nDefault value: \"graphQLTag\"" }, "optimizeDocumentNode": { "description": "If you are using `documentNode: documentMode | documentNodeImportFragments`, you can set this to `true` to apply document optimizations for your GraphQL document.\nThis will remove all \"loc\" and \"description\" fields from the compiled document, and will remove all empty arrays (such as `directives`, `arguments` and `variableDefinitions`).\nDefault value: \"true\"", @@ -1409,7 +1523,7 @@ "type": "boolean" }, "urqlImportFrom": { - "description": "You can specify module that exports components `Query`, `Mutation`, `Subscription` and HOCs\r\nThis is useful for further abstraction of some common tasks (eg. error handling).\r\nFilepath relative to generated file can be also specified.\nDefault value: \"urql\"", + "description": "You can specify module that exports components `Query`, `Mutation`, `Subscription` and HOCs\nThis is useful for further abstraction of some common tasks (eg. error handling).\nFilepath relative to generated file can be also specified.\nDefault value: \"urql\"", "type": "string" }, "noGraphQLTag": { @@ -1458,7 +1572,7 @@ }, "documentMode": { "$ref": "#/definitions/DocumentMode", - "description": "Declares how DocumentNode are created:\n- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client\n- `documentNode`: document nodes will be generated as objects when we generate the templates.\n- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them.\n- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom`\nDefault value: \"graphQLTag\"" + "description": "Declares how DocumentNode are created:\n- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client\n- `documentNode`: document nodes will be generated as objects when we generate the templates.\n- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them.\n- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom`\n\nNote that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter.\nDefault value: \"graphQLTag\"" }, "optimizeDocumentNode": { "description": "If you are using `documentNode: documentMode | documentNodeImportFragments`, you can set this to `true` to apply document optimizations for your GraphQL document.\nThis will remove all \"loc\" and \"description\" fields from the compiled document, and will remove all empty arrays (such as `directives`, `arguments` and `variableDefinitions`).\nDefault value: \"true\"", @@ -1623,7 +1737,7 @@ }, "documentMode": { "$ref": "#/definitions/DocumentMode", - "description": "Declares how DocumentNode are created:\n- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client\n- `documentNode`: document nodes will be generated as objects when we generate the templates.\n- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them.\n- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom`\nDefault value: \"graphQLTag\"" + "description": "Declares how DocumentNode are created:\n- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client\n- `documentNode`: document nodes will be generated as objects when we generate the templates.\n- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them.\n- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom`\n\nNote that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter.\nDefault value: \"graphQLTag\"" }, "optimizeDocumentNode": { "description": "If you are using `documentNode: documentMode | documentNodeImportFragments`, you can set this to `true` to apply document optimizations for your GraphQL document.\nThis will remove all \"loc\" and \"description\" fields from the compiled document, and will remove all empty arrays (such as `directives`, `arguments` and `variableDefinitions`).\nDefault value: \"true\"", @@ -1741,7 +1855,7 @@ }, "documentMode": { "$ref": "#/definitions/DocumentMode", - "description": "Declares how DocumentNode are created:\n- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client\n- `documentNode`: document nodes will be generated as objects when we generate the templates.\n- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them.\n- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom`\nDefault value: \"graphQLTag\"" + "description": "Declares how DocumentNode are created:\n- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client\n- `documentNode`: document nodes will be generated as objects when we generate the templates.\n- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them.\n- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom`\n\nNote that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter.\nDefault value: \"graphQLTag\"" }, "optimizeDocumentNode": { "description": "If you are using `documentNode: documentMode | documentNodeImportFragments`, you can set this to `true` to apply document optimizations for your GraphQL document.\nThis will remove all \"loc\" and \"description\" fields from the compiled document, and will remove all empty arrays (such as `directives`, `arguments` and `variableDefinitions`).\nDefault value: \"true\"", @@ -1794,7 +1908,7 @@ } }, "StencilApolloRawPluginConfig": { - "description": "This plugin generates Stencil Apollo functional components typings\r\n\r\nIt extends the basic TypeScript plugins: `@graphql-codegen/typescript`, `@graphql-codegen/typescript-operations` - and thus shares a similar configuration.", + "description": "This plugin generates Stencil Apollo functional components typings\n\nIt extends the basic TypeScript plugins: `@graphql-codegen/typescript`, `@graphql-codegen/typescript-operations` - and thus shares a similar configuration.", "type": "object", "properties": { "componentType": { @@ -1847,7 +1961,7 @@ }, "documentMode": { "$ref": "#/definitions/DocumentMode", - "description": "Declares how DocumentNode are created:\n- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client\n- `documentNode`: document nodes will be generated as objects when we generate the templates.\n- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them.\n- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom`\nDefault value: \"graphQLTag\"" + "description": "Declares how DocumentNode are created:\n- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client\n- `documentNode`: document nodes will be generated as objects when we generate the templates.\n- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them.\n- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom`\n\nNote that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter.\nDefault value: \"graphQLTag\"" }, "optimizeDocumentNode": { "description": "If you are using `documentNode: documentMode | documentNodeImportFragments`, you can set this to `true` to apply document optimizations for your GraphQL document.\nThis will remove all \"loc\" and \"description\" fields from the compiled document, and will remove all empty arrays (such as `directives`, `arguments` and `variableDefinitions`).\nDefault value: \"true\"", @@ -1905,7 +2019,7 @@ "properties": { "namingConvention": { "$ref": "#/definitions/NamingConvention", - "description": "Allow you to override the naming convention of the output.\r\nYou can either override all namings, or specify an object with specific custom naming convention per output.\r\nThe format of the converter must be a valid `module#method`.\r\nAllowed values for specific output are: `typeNames`, `enumValues`.\r\nYou can also use \"keep\" to keep all GraphQL names as-is.\r\nAdditionally you can set `transformUnderscore` to `true` if you want to override the default behavior,\r\nwhich is to preserves underscores.\r\n\r\nAvailable case functions in `change-case-all` are `camelCase`, `capitalCase`, `constantCase`, `dotCase`, `headerCase`, `noCase`, `paramCase`, `pascalCase`, `pathCase`, `sentenceCase`, `snakeCase`, `lowerCase`, `localeLowerCase`, `lowerCaseFirst`, `spongeCase`, `titleCase`, `upperCase`, `localeUpperCase` and `upperCaseFirst`\r\n[See more](https://github.com/btxtiger/change-case-all)\nDefault value: \"change-case-all#pascalCase\"" + "description": "Allow you to override the naming convention of the output.\nYou can either override all namings, or specify an object with specific custom naming convention per output.\nThe format of the converter must be a valid `module#method`.\nAllowed values for specific output are: `typeNames`, `enumValues`.\nYou can also use \"keep\" to keep all GraphQL names as-is.\nAdditionally you can set `transformUnderscore` to `true` if you want to override the default behavior,\nwhich is to preserves underscores.\n\nAvailable case functions in `change-case-all` are `camelCase`, `capitalCase`, `constantCase`, `dotCase`, `headerCase`, `noCase`, `paramCase`, `pascalCase`, `pathCase`, `sentenceCase`, `snakeCase`, `lowerCase`, `localeLowerCase`, `lowerCaseFirst`, `spongeCase`, `titleCase`, `upperCase`, `localeUpperCase` and `upperCaseFirst`\n[See more](https://github.com/btxtiger/change-case-all)\nDefault value: \"change-case-all#pascalCase\"" }, "namePrefix": { "description": "Adds prefix to the name\nDefault value: \"\"", @@ -1969,7 +2083,7 @@ }, "documentMode": { "$ref": "#/definitions/DocumentMode", - "description": "Declares how DocumentNode are created:\n- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client\n- `documentNode`: document nodes will be generated as objects when we generate the templates.\n- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them.\n- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom`\nDefault value: \"graphQLTag\"" + "description": "Declares how DocumentNode are created:\n- `graphQLTag`: `graphql-tag` or other modules (check `gqlImport`) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the client\n- `documentNode`: document nodes will be generated as objects when we generate the templates.\n- `documentNodeImportFragments`: Similar to documentNode except it imports external fragments instead of embedding them.\n- `external`: document nodes are imported from an external file. To be used with `importDocumentNodeExternallyFrom`\n\nNote that some plugins (like `typescript-graphql-request`) also supports `string` for this parameter.\nDefault value: \"graphQLTag\"" }, "optimizeDocumentNode": { "description": "If you are using `documentNode: documentMode | documentNodeImportFragments`, you can set this to `true` to apply document optimizations for your GraphQL document.\nThis will remove all \"loc\" and \"description\" fields from the compiled document, and will remove all empty arrays (such as `directives`, `arguments` and `variableDefinitions`).\nDefault value: \"true\"", @@ -2074,14 +2188,14 @@ "type": "string" }, "mappers": { - "description": "Allow you to replace specific GraphQL types with your custom model classes. This is useful when you want to make sure your resolvers returns the correct class.\r\nThe default value is the values set by `defaultMapper` configuration.\r\nYou can use a direct path to the package, or use `package#class` syntax to have it imported.", + "description": "Allow you to replace specific GraphQL types with your custom model classes. This is useful when you want to make sure your resolvers returns the correct class.\nThe default value is the values set by `defaultMapper` configuration.\nYou can use a direct path to the package, or use `package#class` syntax to have it imported.", "type": "object", "additionalProperties": { "type": "string" } }, "defaultMapper": { - "description": "Sets the default mapper value in case it's not specified by `mappers`.\r\nYou can use a direct path to the package, or use `package#class` syntax to have it imported.\r\nThe default mapper is Java's `Object`.\nDefault value: \"Object\"", + "description": "Sets the default mapper value in case it's not specified by `mappers`.\nYou can use a direct path to the package, or use `package#class` syntax to have it imported.\nThe default mapper is Java's `Object`.\nDefault value: \"Object\"", "type": "string" }, "className": { @@ -2172,7 +2286,7 @@ } }, "FlowPluginConfig": { - "description": "This plugin generates Flow types based on your `GraphQLSchema`.\r\n\r\nIt generates types for your entire schema: types, input types, enum, interface, scalar and union.", + "description": "This plugin generates Flow types based on your `GraphQLSchema`.\n\nIt generates types for your entire schema: types, input types, enum, interface, scalar and union.", "type": "object", "properties": { "useFlowExactObjects": { @@ -2343,6 +2457,10 @@ "type": "string", "description": "Defines the prefix value used for `__resolveType` and and `__isTypeOf` resolvers.\nIf you are using `mercurius-js`, please set this field to empty string for better compatiblity.\nDefault value: \"'__'\"" }, + "onlyResolveTypeForInterfaces": { + "type": "boolean", + "description": "Turning this flag to `true` will generate resolver siganture that has only `resolveType` for interfaces, forcing developers to write inherited type resolvers in the type itself.\nDefault value: \"false\"" + }, "scalars": { "$ref": "#/definitions/ScalarsMap", "description": "Extends or overrides the built-in scalars and custom GraphQL scalars to a custom type." @@ -2374,7 +2492,7 @@ } }, "FlowDocumentsPluginConfig": { - "description": "This plugin generates Flow types based on your `GraphQLSchema` and your GraphQL operations and fragments.\r\n\r\nIt generates types for your GraphQL documents: Query, Mutation, Subscription and Fragment.\r\n\r\nThis plugin requires you to use `@graphql-codegen/flow` as well, because it depends on it's types.", + "description": "This plugin generates Flow types based on your `GraphQLSchema` and your GraphQL operations and fragments.\n\nIt generates types for your GraphQL documents: Query, Mutation, Subscription and Fragment.\n\nThis plugin requires you to use `@graphql-codegen/flow` as well, because it depends on it's types.", "type": "object", "properties": { "useFlowExactObjects": { @@ -2915,6 +3033,25 @@ } } }, + { + "if": { + "properties": { + "plugins": { + "contains": { + "type": "string", + "const": "typescript-generic-sdk" + } + } + } + }, + "then": { + "properties": { + "config": { + "$ref": "#/definitions/RawGenericSdkPluginConfig" + } + } + } + }, { "if": { "properties": { @@ -3670,6 +3807,10 @@ } } }, + "DocumentMode": { + "enum": ["documentNode", "documentNodeImportFragments", "external", "graphQLTag", "string"], + "type": "string" + }, "AvoidOptionalsConfig": { "type": "object", "properties": { @@ -3745,10 +3886,6 @@ "enum": ["abstract class", "class", "interface", "type"], "type": "string" }, - "DocumentMode": { - "enum": ["documentNode", "documentNodeImportFragments", "external", "graphQLTag", "string"], - "type": "string" - }, "__type_5": { "description": "Make all properties in T optional", "type": "object", @@ -3801,6 +3938,14 @@ "additionalProperties": false, "$ref": "#/definitions/ReactQueryRawPluginConfig" }, + "typescript-generic-sdk": { + "additionalProperties": false, + "$ref": "#/definitions/RawGenericSdkPluginConfig" + }, + "@graphql-codegen/typescript-generic-sdk": { + "additionalProperties": false, + "$ref": "#/definitions/RawGenericSdkPluginConfig" + }, "typescript-apollo-client-helpers": { "additionalProperties": false, "$ref": "#/definitions/ApolloClientHelpersConfig" @@ -4062,6 +4207,14 @@ "const": "@graphql-codegen/typescript-react-query", "description": "This plugin generates `React-Query` Hooks with TypeScript typings.\n\nIt extends the basic TypeScript plugins: `@graphql-codegen/typescript`, `@graphql-codegen/typescript-operations` - and thus shares a similar configuration.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/typescript-react-query\n\n=> Make sure to include \"@graphql-codegen/typescript-react-query\" in your package.json file and install your dependencies.\n\n" }, + { + "const": "typescript-generic-sdk", + "description": "This plugin generate a generic SDK (without any Requester implemented), allow you to easily customize the way you fetch your data, without loosing the strongly-typed integration.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/typescript-generic-sdk\n\n=> Make sure to include \"@graphql-codegen/typescript-generic-sdk\" in your package.json file and install your dependencies.\n\n" + }, + { + "const": "@graphql-codegen/typescript-generic-sdk", + "description": "This plugin generate a generic SDK (without any Requester implemented), allow you to easily customize the way you fetch your data, without loosing the strongly-typed integration.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/typescript-generic-sdk\n\n=> Make sure to include \"@graphql-codegen/typescript-generic-sdk\" in your package.json file and install your dependencies.\n\n" + }, { "const": "typescript-apollo-client-helpers", "description": "\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/typescript-apollo-client-helpers\n\n=> Make sure to include \"@graphql-codegen/typescript-apollo-client-helpers\" in your package.json file and install your dependencies.\n\n" @@ -4160,11 +4313,11 @@ }, { "const": "typescript-compatibility", - "description": "If you are migrating from <1.0, we created a new plugin called `typescript-compatibility` that generates backward compatibility for the `typescript-operations` and `typescript-react-apollo` plugins.\r\n\r\nIt generates types that are pointing to the new form of types. It supports _most_ of the use-cases.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/typescript-compatibility\n\n=> Make sure to include \"@graphql-codegen/typescript-compatibility\" in your package.json file and install your dependencies.\n\n" + "description": "If you are migrating from <1.0, we created a new plugin called `typescript-compatibility` that generates backward compatibility for the `typescript-operations` and `typescript-react-apollo` plugins.\n\nIt generates types that are pointing to the new form of types. It supports _most_ of the use-cases.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/typescript-compatibility\n\n=> Make sure to include \"@graphql-codegen/typescript-compatibility\" in your package.json file and install your dependencies.\n\n" }, { "const": "@graphql-codegen/typescript-compatibility", - "description": "If you are migrating from <1.0, we created a new plugin called `typescript-compatibility` that generates backward compatibility for the `typescript-operations` and `typescript-react-apollo` plugins.\r\n\r\nIt generates types that are pointing to the new form of types. It supports _most_ of the use-cases.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/typescript-compatibility\n\n=> Make sure to include \"@graphql-codegen/typescript-compatibility\" in your package.json file and install your dependencies.\n\n" + "description": "If you are migrating from <1.0, we created a new plugin called `typescript-compatibility` that generates backward compatibility for the `typescript-operations` and `typescript-react-apollo` plugins.\n\nIt generates types that are pointing to the new form of types. It supports _most_ of the use-cases.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/typescript-compatibility\n\n=> Make sure to include \"@graphql-codegen/typescript-compatibility\" in your package.json file and install your dependencies.\n\n" }, { "const": "typescript-mongodb", @@ -4176,11 +4329,11 @@ }, { "const": "typescript-resolvers", - "description": "This plugin generates TypeScript signature for `resolve` functions of your GraphQL API.\r\nYou can use this plugin a to generate simple resolvers signature based on your GraphQL types, or you can change it's behavior be providing custom model types (mappers).\r\n\r\nYou can find a blog post explaining the usage of this plugin here: https://the-guild.dev/blog/better-type-safety-for-resolvers-with-graphql-codegen\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/typescript-resolvers\n\n=> Make sure to include \"@graphql-codegen/typescript-resolvers\" in your package.json file and install your dependencies.\n\n" + "description": "This plugin generates TypeScript signature for `resolve` functions of your GraphQL API.\nYou can use this plugin a to generate simple resolvers signature based on your GraphQL types, or you can change it's behavior be providing custom model types (mappers).\n\nYou can find a blog post explaining the usage of this plugin here: https://the-guild.dev/blog/better-type-safety-for-resolvers-with-graphql-codegen\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/typescript-resolvers\n\n=> Make sure to include \"@graphql-codegen/typescript-resolvers\" in your package.json file and install your dependencies.\n\n" }, { "const": "@graphql-codegen/typescript-resolvers", - "description": "This plugin generates TypeScript signature for `resolve` functions of your GraphQL API.\r\nYou can use this plugin a to generate simple resolvers signature based on your GraphQL types, or you can change it's behavior be providing custom model types (mappers).\r\n\r\nYou can find a blog post explaining the usage of this plugin here: https://the-guild.dev/blog/better-type-safety-for-resolvers-with-graphql-codegen\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/typescript-resolvers\n\n=> Make sure to include \"@graphql-codegen/typescript-resolvers\" in your package.json file and install your dependencies.\n\n" + "description": "This plugin generates TypeScript signature for `resolve` functions of your GraphQL API.\nYou can use this plugin a to generate simple resolvers signature based on your GraphQL types, or you can change it's behavior be providing custom model types (mappers).\n\nYou can find a blog post explaining the usage of this plugin here: https://the-guild.dev/blog/better-type-safety-for-resolvers-with-graphql-codegen\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/typescript-resolvers\n\n=> Make sure to include \"@graphql-codegen/typescript-resolvers\" in your package.json file and install your dependencies.\n\n" }, { "const": "typescript-apollo-angular", @@ -4216,11 +4369,11 @@ }, { "const": "typescript-stencil-apollo", - "description": "This plugin generates Stencil Apollo functional components typings\r\n\r\nIt extends the basic TypeScript plugins: `@graphql-codegen/typescript`, `@graphql-codegen/typescript-operations` - and thus shares a similar configuration.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/typescript-stencil-apollo\n\n=> Make sure to include \"@graphql-codegen/typescript-stencil-apollo\" in your package.json file and install your dependencies.\n\n" + "description": "This plugin generates Stencil Apollo functional components typings\n\nIt extends the basic TypeScript plugins: `@graphql-codegen/typescript`, `@graphql-codegen/typescript-operations` - and thus shares a similar configuration.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/typescript-stencil-apollo\n\n=> Make sure to include \"@graphql-codegen/typescript-stencil-apollo\" in your package.json file and install your dependencies.\n\n" }, { "const": "@graphql-codegen/typescript-stencil-apollo", - "description": "This plugin generates Stencil Apollo functional components typings\r\n\r\nIt extends the basic TypeScript plugins: `@graphql-codegen/typescript`, `@graphql-codegen/typescript-operations` - and thus shares a similar configuration.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/typescript-stencil-apollo\n\n=> Make sure to include \"@graphql-codegen/typescript-stencil-apollo\" in your package.json file and install your dependencies.\n\n" + "description": "This plugin generates Stencil Apollo functional components typings\n\nIt extends the basic TypeScript plugins: `@graphql-codegen/typescript`, `@graphql-codegen/typescript-operations` - and thus shares a similar configuration.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/typescript-stencil-apollo\n\n=> Make sure to include \"@graphql-codegen/typescript-stencil-apollo\" in your package.json file and install your dependencies.\n\n" }, { "const": "typescript-document-nodes", @@ -4264,11 +4417,11 @@ }, { "const": "flow", - "description": "This plugin generates Flow types based on your `GraphQLSchema`.\r\n\r\nIt generates types for your entire schema: types, input types, enum, interface, scalar and union.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/flow\n\n=> Make sure to include \"@graphql-codegen/flow\" in your package.json file and install your dependencies.\n\n" + "description": "This plugin generates Flow types based on your `GraphQLSchema`.\n\nIt generates types for your entire schema: types, input types, enum, interface, scalar and union.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/flow\n\n=> Make sure to include \"@graphql-codegen/flow\" in your package.json file and install your dependencies.\n\n" }, { "const": "@graphql-codegen/flow", - "description": "This plugin generates Flow types based on your `GraphQLSchema`.\r\n\r\nIt generates types for your entire schema: types, input types, enum, interface, scalar and union.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/flow\n\n=> Make sure to include \"@graphql-codegen/flow\" in your package.json file and install your dependencies.\n\n" + "description": "This plugin generates Flow types based on your `GraphQLSchema`.\n\nIt generates types for your entire schema: types, input types, enum, interface, scalar and union.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/flow\n\n=> Make sure to include \"@graphql-codegen/flow\" in your package.json file and install your dependencies.\n\n" }, { "const": "flow-resolvers", @@ -4280,11 +4433,11 @@ }, { "const": "flow-operations", - "description": "This plugin generates Flow types based on your `GraphQLSchema` and your GraphQL operations and fragments.\r\n\r\nIt generates types for your GraphQL documents: Query, Mutation, Subscription and Fragment.\r\n\r\nThis plugin requires you to use `@graphql-codegen/flow` as well, because it depends on it's types.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/flow-operations\n\n=> Make sure to include \"@graphql-codegen/flow-operations\" in your package.json file and install your dependencies.\n\n" + "description": "This plugin generates Flow types based on your `GraphQLSchema` and your GraphQL operations and fragments.\n\nIt generates types for your GraphQL documents: Query, Mutation, Subscription and Fragment.\n\nThis plugin requires you to use `@graphql-codegen/flow` as well, because it depends on it's types.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/flow-operations\n\n=> Make sure to include \"@graphql-codegen/flow-operations\" in your package.json file and install your dependencies.\n\n" }, { "const": "@graphql-codegen/flow-operations", - "description": "This plugin generates Flow types based on your `GraphQLSchema` and your GraphQL operations and fragments.\r\n\r\nIt generates types for your GraphQL documents: Query, Mutation, Subscription and Fragment.\r\n\r\nThis plugin requires you to use `@graphql-codegen/flow` as well, because it depends on it's types.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/flow-operations\n\n=> Make sure to include \"@graphql-codegen/flow-operations\" in your package.json file and install your dependencies.\n\n" + "description": "This plugin generates Flow types based on your `GraphQLSchema` and your GraphQL operations and fragments.\n\nIt generates types for your GraphQL documents: Query, Mutation, Subscription and Fragment.\n\nThis plugin requires you to use `@graphql-codegen/flow` as well, because it depends on it's types.\n\nFor more details and documentation: https://graphql-code-generator.com/docs/plugins/flow-operations\n\n=> Make sure to include \"@graphql-codegen/flow-operations\" in your package.json file and install your dependencies.\n\n" }, { "const": "introspection",