@graphql-codegen/client-preset 2.1.1 → 2.1.2-alpha-20230309105403-13e48a92e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.plugin = void 0;
4
4
  const fragmentTypeHelper = `
5
- export type FragmentType<TDocumentType extends DocumentNode<any, any>> = TDocumentType extends DocumentNode<
5
+ export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<
6
6
  infer TType,
7
7
  any
8
8
  >
@@ -14,7 +14,7 @@ export type FragmentType<TDocumentType extends DocumentNode<any, any>> = TDocume
14
14
  : never;`;
15
15
  const makeFragmentDataHelper = `
16
16
  export function makeFragmentData<
17
- F extends DocumentNode,
17
+ F extends DocumentTypeDecoration<any, any>,
18
18
  FT extends ResultOf<F>
19
19
  >(data: FT, _fragment: F): FragmentType<F> {
20
20
  return data as FragmentType<F>;
@@ -26,8 +26,8 @@ const modifyType = (rawType, opts) => `${opts.list === 'only-list'
26
26
  ? `${rawType} | ReadonlyArray<${rawType}>`
27
27
  : rawType}${opts.nullable ? ' | null | undefined' : ''}`;
28
28
  const createUnmaskFunctionTypeDefinition = (unmaskFunctionName = defaultUnmaskFunctionName, opts) => `export function ${unmaskFunctionName}<TType>(
29
- _documentNode: DocumentNode<TType, any>,
30
- fragmentType: ${modifyType('FragmentType<DocumentNode<TType, any>>', opts)}
29
+ _documentNode: DocumentTypeDecoration<TType, any>,
30
+ fragmentType: ${modifyType('FragmentType<DocumentTypeDecoration<TType, any>>', opts)}
31
31
  ): ${modifyType('TType', opts)}`;
32
32
  const createUnmaskFunctionTypeDefinitions = (unmaskFunctionName = defaultUnmaskFunctionName) => [
33
33
  `// return non-nullable if \`fragmentType\` is non-nullable\n${createUnmaskFunctionTypeDefinition(unmaskFunctionName, { nullable: false, list: false })}`,
@@ -49,7 +49,7 @@ ${createUnmaskFunctionTypeDefinitions(unmaskFunctionName)
49
49
  * Plugin for generating fragment masking helper functions.
50
50
  */
51
51
  const plugin = (_, __, { useTypeImports, augmentedModuleName, unmaskFunctionName }, _info) => {
52
- const documentNodeImport = `${useTypeImports ? 'import type' : 'import'} { ResultOf, TypedDocumentNode as DocumentNode, } from '@graphql-typed-document-node/core';\n`;
52
+ const documentNodeImport = `${useTypeImports ? 'import type' : 'import'} { ResultOf, DocumentTypeDecoration, } from '@graphql-typed-document-node/core';\n`;
53
53
  if (augmentedModuleName == null) {
54
54
  return [
55
55
  documentNodeImport,
package/cjs/index.js CHANGED
@@ -39,6 +39,7 @@ exports.preset = {
39
39
  dedupeFragments: options.config.dedupeFragments,
40
40
  nonOptionalTypename: options.config.nonOptionalTypename,
41
41
  avoidOptionals: options.config.avoidOptionals,
42
+ documentMode: options.config.documentMode,
42
43
  };
43
44
  const visitor = new visitor_plugin_common_1.ClientSideBaseVisitor(options.schemaAst, [], options.config, options.config);
44
45
  let fragmentMaskingConfig = null;
@@ -1,5 +1,5 @@
1
1
  const fragmentTypeHelper = `
2
- export type FragmentType<TDocumentType extends DocumentNode<any, any>> = TDocumentType extends DocumentNode<
2
+ export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<
3
3
  infer TType,
4
4
  any
5
5
  >
@@ -11,7 +11,7 @@ export type FragmentType<TDocumentType extends DocumentNode<any, any>> = TDocume
11
11
  : never;`;
12
12
  const makeFragmentDataHelper = `
13
13
  export function makeFragmentData<
14
- F extends DocumentNode,
14
+ F extends DocumentTypeDecoration<any, any>,
15
15
  FT extends ResultOf<F>
16
16
  >(data: FT, _fragment: F): FragmentType<F> {
17
17
  return data as FragmentType<F>;
@@ -23,8 +23,8 @@ const modifyType = (rawType, opts) => `${opts.list === 'only-list'
23
23
  ? `${rawType} | ReadonlyArray<${rawType}>`
24
24
  : rawType}${opts.nullable ? ' | null | undefined' : ''}`;
25
25
  const createUnmaskFunctionTypeDefinition = (unmaskFunctionName = defaultUnmaskFunctionName, opts) => `export function ${unmaskFunctionName}<TType>(
26
- _documentNode: DocumentNode<TType, any>,
27
- fragmentType: ${modifyType('FragmentType<DocumentNode<TType, any>>', opts)}
26
+ _documentNode: DocumentTypeDecoration<TType, any>,
27
+ fragmentType: ${modifyType('FragmentType<DocumentTypeDecoration<TType, any>>', opts)}
28
28
  ): ${modifyType('TType', opts)}`;
29
29
  const createUnmaskFunctionTypeDefinitions = (unmaskFunctionName = defaultUnmaskFunctionName) => [
30
30
  `// return non-nullable if \`fragmentType\` is non-nullable\n${createUnmaskFunctionTypeDefinition(unmaskFunctionName, { nullable: false, list: false })}`,
@@ -46,7 +46,7 @@ ${createUnmaskFunctionTypeDefinitions(unmaskFunctionName)
46
46
  * Plugin for generating fragment masking helper functions.
47
47
  */
48
48
  export const plugin = (_, __, { useTypeImports, augmentedModuleName, unmaskFunctionName }, _info) => {
49
- const documentNodeImport = `${useTypeImports ? 'import type' : 'import'} { ResultOf, TypedDocumentNode as DocumentNode, } from '@graphql-typed-document-node/core';\n`;
49
+ const documentNodeImport = `${useTypeImports ? 'import type' : 'import'} { ResultOf, DocumentTypeDecoration, } from '@graphql-typed-document-node/core';\n`;
50
50
  if (augmentedModuleName == null) {
51
51
  return [
52
52
  documentNodeImport,
package/esm/index.js CHANGED
@@ -34,6 +34,7 @@ export const preset = {
34
34
  dedupeFragments: options.config.dedupeFragments,
35
35
  nonOptionalTypename: options.config.nonOptionalTypename,
36
36
  avoidOptionals: options.config.avoidOptionals,
37
+ documentMode: options.config.documentMode,
37
38
  };
38
39
  const visitor = new ClientSideBaseVisitor(options.schemaAst, [], options.config, options.config);
39
40
  let fragmentMaskingConfig = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/client-preset",
3
- "version": "2.1.1",
3
+ "version": "2.1.2-alpha-20230309105403-13e48a92e",
4
4
  "description": "GraphQL Code Generator preset for client.",
5
5
  "peerDependencies": {
6
6
  "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
@@ -13,9 +13,9 @@
13
13
  "@graphql-codegen/typescript": "^3.0.2",
14
14
  "@graphql-codegen/typescript-operations": "^3.0.2",
15
15
  "@graphql-codegen/gql-tag-operations": "2.0.2",
16
- "@graphql-codegen/plugin-helpers": "^4.1.0",
16
+ "@graphql-codegen/plugin-helpers": "4.1.1-alpha-20230309105403-13e48a92e",
17
17
  "@graphql-codegen/visitor-plugin-common": "^3.0.2",
18
- "@graphql-typed-document-node/core": "3.1.2",
18
+ "@graphql-typed-document-node/core": "3.2.0-alpha-20230309104331-975d9d2",
19
19
  "@graphql-tools/documents": "^0.1.0",
20
20
  "@graphql-tools/utils": "^9.0.0",
21
21
  "tslib": "~2.5.0"