@graphcommerce/graphql-codegen-relay-optimizer-plugin 5.1.0-canary.2 → 5.1.0-canary.4

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.
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
3
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
4
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
5
  if (ar || !(i in from)) {
@@ -13,15 +14,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
14
  };
14
15
  Object.defineProperty(exports, "__esModule", { value: true });
15
16
  exports.plugin = void 0;
17
+ var CompilerContext_1 = __importDefault(require("@ardatan/relay-compiler/lib/core/CompilerContext"));
18
+ var IRPrinter_1 = require("@ardatan/relay-compiler/lib/core/IRPrinter");
19
+ var RelayParser_1 = require("@ardatan/relay-compiler/lib/core/RelayParser");
20
+ var Schema_1 = require("@ardatan/relay-compiler/lib/core/Schema");
21
+ var ApplyFragmentArgumentTransform_1 = require("@ardatan/relay-compiler/lib/transforms/ApplyFragmentArgumentTransform");
22
+ var FlattenTransform_1 = require("@ardatan/relay-compiler/lib/transforms/FlattenTransform");
23
+ var InlineFragmentsTransform_1 = require("@ardatan/relay-compiler/lib/transforms/InlineFragmentsTransform");
24
+ var SkipRedundantNodesTransform_1 = require("@ardatan/relay-compiler/lib/transforms/SkipRedundantNodesTransform");
16
25
  var graphql_1 = require("graphql");
17
- var relay_compiler_1 = require("relay-compiler");
18
- var CompilerContext_1 = __importDefault(require("relay-compiler/lib/core/CompilerContext"));
19
- var IRPrinter_1 = require("relay-compiler/lib/core/IRPrinter");
20
- var Schema_1 = require("relay-compiler/lib/core/Schema");
21
- var ApplyFragmentArgumentTransform_1 = require("relay-compiler/lib/transforms/ApplyFragmentArgumentTransform");
22
- var FlattenTransform_1 = require("relay-compiler/lib/transforms/FlattenTransform");
23
- var InlineFragmentsTransform_1 = require("relay-compiler/lib/transforms/InlineFragmentsTransform");
24
- var SkipRedundantNodesTransform_1 = require("relay-compiler/lib/transforms/SkipRedundantNodesTransform");
25
26
  function isFragment(documentFile) {
26
27
  var name = false;
27
28
  if (!documentFile.document)
@@ -46,7 +47,7 @@ _config) {
46
47
  /* GraphQL */ "\n directive @connection(key: String!, filter: [String!]) on FIELD\n directive @client on FIELD\n ",
47
48
  ]);
48
49
  var documentAsts = documents.reduce(function (prev, v) { var _a, _b; return __spreadArray(__spreadArray([], prev, true), ((_b = (_a = v.document) === null || _a === void 0 ? void 0 : _a.definitions) !== null && _b !== void 0 ? _b : []), true); }, []);
49
- var relayDocuments = relay_compiler_1.Parser.transform(adjustedSchema, documentAsts);
50
+ var relayDocuments = (0, RelayParser_1.transform)(adjustedSchema, documentAsts);
50
51
  var fragmentCompilerContext = new CompilerContext_1.default(adjustedSchema).addAll(relayDocuments);
51
52
  var fragmentDocuments = fragmentCompilerContext
52
53
  .applyTransforms([
@@ -1,12 +1,13 @@
1
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
+ import CompilerContext from '@ardatan/relay-compiler/lib/core/CompilerContext';
3
+ import { print as relayPrint } from '@ardatan/relay-compiler/lib/core/IRPrinter';
4
+ import { transform as relayParserTransform } from '@ardatan/relay-compiler/lib/core/RelayParser';
5
+ import { create as relayCreate } from '@ardatan/relay-compiler/lib/core/Schema';
6
+ import { transform as applyFragmentArgumentTransform } from '@ardatan/relay-compiler/lib/transforms/ApplyFragmentArgumentTransform';
7
+ import { transformWithOptions as flattenTransformWithOptions } from '@ardatan/relay-compiler/lib/transforms/FlattenTransform';
8
+ import { transform as inlineFragmentsTransform } from '@ardatan/relay-compiler/lib/transforms/InlineFragmentsTransform';
9
+ import { transform as skipRedundantNodesTransform } from '@ardatan/relay-compiler/lib/transforms/SkipRedundantNodesTransform';
1
10
  import { parse, printSchema, visit } from 'graphql';
2
- import { Parser as RelayParser } from 'relay-compiler';
3
- import CompilerContext from 'relay-compiler/lib/core/CompilerContext';
4
- import { print as relayPrint } from 'relay-compiler/lib/core/IRPrinter';
5
- import { create as relayCreate } from 'relay-compiler/lib/core/Schema';
6
- import { transform as applyFragmentArgumentTransform } from 'relay-compiler/lib/transforms/ApplyFragmentArgumentTransform';
7
- import { transformWithOptions as flattenTransformWithOptions } from 'relay-compiler/lib/transforms/FlattenTransform';
8
- import { transform as inlineFragmentsTransform } from 'relay-compiler/lib/transforms/InlineFragmentsTransform';
9
- import { transform as skipRedundantNodesTransform } from 'relay-compiler/lib/transforms/SkipRedundantNodesTransform';
10
11
  function isFragment(documentFile) {
11
12
  let name = false;
12
13
  if (!documentFile.document)
@@ -34,7 +35,7 @@ _config) => {
34
35
  `,
35
36
  ]);
36
37
  const documentAsts = documents.reduce((prev, v) => { var _a, _b; return [...prev, ...((_b = (_a = v.document) === null || _a === void 0 ? void 0 : _a.definitions) !== null && _b !== void 0 ? _b : [])]; }, []);
37
- const relayDocuments = RelayParser.transform(adjustedSchema, documentAsts);
38
+ const relayDocuments = relayParserTransform(adjustedSchema, documentAsts);
38
39
  const fragmentCompilerContext = new CompilerContext(adjustedSchema).addAll(relayDocuments);
39
40
  const fragmentDocuments = fragmentCompilerContext
40
41
  .applyTransforms([
package/package.json CHANGED
@@ -2,35 +2,24 @@
2
2
  "name": "@graphcommerce/graphql-codegen-relay-optimizer-plugin",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "5.1.0-canary.2",
5
+ "version": "5.1.0-canary.4",
6
6
  "description": "GraphQL Code Generator plugin for optimizing your GraphQL queries relay style.",
7
7
  "license": "MIT",
8
8
  "main": "dist/main/index.js",
9
9
  "module": "dist/module/index.js",
10
- "keywords": [
11
- "graphql",
12
- "codegen",
13
- "graphql-codegen",
14
- "plugin",
15
- "relay"
16
- ],
17
- "peerDependencies": {
18
- "graphql": "14.x.x || 15.x.x || 16.x.x"
19
- },
20
10
  "dependencies": {
21
- "@graphql-codegen/plugin-helpers": "2.6.2",
22
- "relay-compiler": "12.0.0"
11
+ "@graphql-codegen/plugin-helpers": "2.7.2",
12
+ "@ardatan/relay-compiler": "12.0.0",
13
+ "graphql": "16.6.0"
23
14
  },
24
15
  "devDependencies": {
25
- "@graphcommerce/eslint-config-pwa": "^5.1.0-canary.2",
26
- "@graphcommerce/prettier-config-pwa": "^5.1.0-canary.2",
27
- "@graphql-codegen/testing": "1.17.7",
28
- "@types/jest": "28.1.4",
16
+ "@graphcommerce/eslint-config-pwa": "5.1.0-canary.4",
17
+ "@graphcommerce/prettier-config-pwa": "5.1.0-canary.4",
18
+ "@types/jest": "29.2.3",
29
19
  "@types/relay-compiler": "8.0.3",
30
- "graphql": "16.5.0",
31
- "jest": "28.1.2",
32
- "ts-jest": "28.0.5",
33
- "typescript": "4.7.4"
20
+ "jest": "29.3.1",
21
+ "ts-jest": "29.0.3",
22
+ "typescript": "4.9.3"
34
23
  },
35
24
  "scripts": {
36
25
  "test": "jest",
@@ -1,4 +1,4 @@
1
- import '@graphql-codegen/testing'
1
+ // import '@graphql-codegen/testing'
2
2
  import { Types } from '@graphql-codegen/plugin-helpers'
3
3
  import { buildSchema, parse, print, ASTNode } from 'graphql'
4
4
  import { plugin } from '..'
package/src/index.ts CHANGED
@@ -1,17 +1,16 @@
1
1
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
+
3
+ import CompilerContext from '@ardatan/relay-compiler/lib/core/CompilerContext'
4
+ import { print as relayPrint } from '@ardatan/relay-compiler/lib/core/IRPrinter'
5
+ import { transform as relayParserTransform } from '@ardatan/relay-compiler/lib/core/RelayParser'
6
+ import { create as relayCreate } from '@ardatan/relay-compiler/lib/core/Schema'
7
+ import { transform as applyFragmentArgumentTransform } from '@ardatan/relay-compiler/lib/transforms/ApplyFragmentArgumentTransform'
8
+ import { transformWithOptions as flattenTransformWithOptions } from '@ardatan/relay-compiler/lib/transforms/FlattenTransform'
9
+ import { transform as inlineFragmentsTransform } from '@ardatan/relay-compiler/lib/transforms/InlineFragmentsTransform'
10
+ import { transform as skipRedundantNodesTransform } from '@ardatan/relay-compiler/lib/transforms/SkipRedundantNodesTransform'
2
11
  import { Types, PluginFunction } from '@graphql-codegen/plugin-helpers'
3
12
  import { GraphQLSchema, parse, printSchema, DefinitionNode, visit } from 'graphql'
4
13
 
5
- import { Parser as RelayParser } from 'relay-compiler'
6
- import CompilerContext from 'relay-compiler/lib/core/CompilerContext'
7
- import { print as relayPrint } from 'relay-compiler/lib/core/IRPrinter'
8
- import { create as relayCreate } from 'relay-compiler/lib/core/Schema'
9
-
10
- import { transform as applyFragmentArgumentTransform } from 'relay-compiler/lib/transforms/ApplyFragmentArgumentTransform'
11
- import { transformWithOptions as flattenTransformWithOptions } from 'relay-compiler/lib/transforms/FlattenTransform'
12
- import { transform as inlineFragmentsTransform } from 'relay-compiler/lib/transforms/InlineFragmentsTransform'
13
- import { transform as skipRedundantNodesTransform } from 'relay-compiler/lib/transforms/SkipRedundantNodesTransform'
14
-
15
14
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
16
15
  export interface RelayOptimizerPluginConfig {}
17
16
 
@@ -52,7 +51,7 @@ export const plugin: PluginFunction<RelayOptimizerPluginConfig> = (
52
51
  [] as DefinitionNode[],
53
52
  )
54
53
 
55
- const relayDocuments = RelayParser.transform(adjustedSchema, documentAsts)
54
+ const relayDocuments = relayParserTransform(adjustedSchema, documentAsts)
56
55
 
57
56
  const fragmentCompilerContext = new CompilerContext(adjustedSchema).addAll(relayDocuments)
58
57
 
package/src/types.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ declare module '@ardatan/relay-compiler/lib/core/Schema' {
2
+ export function create(schema: string): import('relay-compiler').Schema
3
+ }
4
+
5
+ declare module '@ardatan/relay-compiler/lib/core/IRPrinter' {
6
+ export function print(schema: import('relay-compiler').Schema, document: any): string
7
+ }
8
+
9
+ declare module '@ardatan/relay-compiler/lib/core/CompilerContext' {
10
+ let CompilerContext: typeof import('relay-compiler').CompilerContext
11
+ export = CompilerContext
12
+ }
13
+
14
+ declare module '@ardatan/relay-compiler/lib/transforms/SkipRedundantNodesTransform' {
15
+ let transform: typeof import('relay-compiler/lib/transforms/SkipRedundantNodesTransform.js')
16
+ export = transform
17
+ }
18
+
19
+ declare module '@ardatan/relay-compiler/lib/transforms/InlineFragmentsTransform' {
20
+ let transform: typeof import('relay-compiler/lib/transforms/InlineFragmentsTransform.js')
21
+ export = transform
22
+ }
23
+
24
+ declare module '@ardatan/relay-compiler/lib/transforms/ApplyFragmentArgumentTransform' {
25
+ let transform: typeof import('relay-compiler/lib/transforms/ApplyFragmentArgumentTransform.js')
26
+ export = transform
27
+ }
28
+
29
+ declare module '@ardatan/relay-compiler/lib/transforms/FlattenTransform' {
30
+ let transform: typeof import('relay-compiler/lib/transforms/FlattenTransform.js')
31
+ export = transform
32
+ }
33
+
34
+ declare module '@ardatan/relay-compiler/lib/core/RelayParser' {
35
+ let RelayParser: typeof import('relay-compiler/lib/core/RelayParser.js')
36
+ export = RelayParser
37
+ }
package/src/tyes.d.ts DELETED
@@ -1,12 +0,0 @@
1
- declare module 'relay-compiler/lib/core/Schema' {
2
- export function create(schema: string): import('relay-compiler').Schema
3
- }
4
-
5
- declare module 'relay-compiler/lib/core/IRPrinter' {
6
- export function print(schema: import('relay-compiler').Schema, document: unknown): string
7
- }
8
-
9
- declare module 'relay-compiler/lib/core/CompilerContext' {
10
- let CompilerContext: typeof import('relay-compiler').CompilerContext
11
- export = CompilerContext
12
- }