@graphql-mesh/store 0.9.0-alpha-d63361380.0 → 1.0.0-alpha-c34a7d66e.0
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.
- package/index.d.ts +3 -15
- package/index.js +42 -6
- package/index.mjs +42 -6
- package/package.json +5 -3
package/index.d.ts
CHANGED
|
@@ -46,22 +46,10 @@ export declare type StoreFlags = {
|
|
|
46
46
|
};
|
|
47
47
|
export declare enum PredefinedProxyOptionsName {
|
|
48
48
|
JsonWithoutValidation = "JsonWithoutValidation",
|
|
49
|
-
StringWithoutValidation = "StringWithoutValidation"
|
|
49
|
+
StringWithoutValidation = "StringWithoutValidation",
|
|
50
|
+
GraphQLSchemaWithDiffing = "GraphQLSchemaWithDiffing"
|
|
50
51
|
}
|
|
51
|
-
export declare const PredefinedProxyOptions:
|
|
52
|
-
readonly JsonWithoutValidation: {
|
|
53
|
-
readonly codify: (v: any) => string;
|
|
54
|
-
readonly fromJSON: (v: any) => any;
|
|
55
|
-
readonly toJSON: (v: any) => any;
|
|
56
|
-
readonly validate: () => void;
|
|
57
|
-
};
|
|
58
|
-
readonly StringWithoutValidation: {
|
|
59
|
-
readonly codify: (v: string) => string;
|
|
60
|
-
readonly fromJSON: (v: string) => string;
|
|
61
|
-
readonly toJSON: (v: string) => string;
|
|
62
|
-
readonly validate: () => void;
|
|
63
|
-
};
|
|
64
|
-
};
|
|
52
|
+
export declare const PredefinedProxyOptions: Record<PredefinedProxyOptionsName, ProxyOptions<any>>;
|
|
65
53
|
export declare class MeshStore {
|
|
66
54
|
identifier: string;
|
|
67
55
|
protected storage: StoreStorageAdapter;
|
package/index.js
CHANGED
|
@@ -4,6 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const crossHelpers = require('@graphql-mesh/cross-helpers');
|
|
6
6
|
const utils = require('@graphql-mesh/utils');
|
|
7
|
+
const core = require('@graphql-inspector/core');
|
|
8
|
+
const utils$1 = require('@graphql-tools/utils');
|
|
9
|
+
const graphql = require('graphql');
|
|
7
10
|
|
|
8
11
|
class ReadonlyStoreError extends Error {
|
|
9
12
|
}
|
|
@@ -69,20 +72,53 @@ class FsStoreStorageAdapter {
|
|
|
69
72
|
(function (PredefinedProxyOptionsName) {
|
|
70
73
|
PredefinedProxyOptionsName["JsonWithoutValidation"] = "JsonWithoutValidation";
|
|
71
74
|
PredefinedProxyOptionsName["StringWithoutValidation"] = "StringWithoutValidation";
|
|
75
|
+
PredefinedProxyOptionsName["GraphQLSchemaWithDiffing"] = "GraphQLSchemaWithDiffing";
|
|
72
76
|
})(exports.PredefinedProxyOptionsName || (exports.PredefinedProxyOptionsName = {}));
|
|
73
77
|
const PredefinedProxyOptions = {
|
|
74
78
|
JsonWithoutValidation: {
|
|
75
|
-
codify:
|
|
76
|
-
fromJSON:
|
|
77
|
-
toJSON:
|
|
79
|
+
codify: v => `export default ${JSON.stringify(v, null, 2)}`,
|
|
80
|
+
fromJSON: v => v,
|
|
81
|
+
toJSON: v => v,
|
|
78
82
|
validate: () => null,
|
|
79
83
|
},
|
|
80
84
|
StringWithoutValidation: {
|
|
81
|
-
codify:
|
|
82
|
-
fromJSON:
|
|
83
|
-
toJSON:
|
|
85
|
+
codify: v => `export default ${JSON.stringify(v, null, 2)}`,
|
|
86
|
+
fromJSON: v => v,
|
|
87
|
+
toJSON: v => v,
|
|
84
88
|
validate: () => null,
|
|
85
89
|
},
|
|
90
|
+
GraphQLSchemaWithDiffing: {
|
|
91
|
+
codify: schema => `
|
|
92
|
+
import { buildASTSchema } from 'graphql';
|
|
93
|
+
|
|
94
|
+
const schemaAST = ${JSON.stringify(utils$1.getDocumentNodeFromSchema(schema), null, 2)};
|
|
95
|
+
|
|
96
|
+
export default buildASTSchema(schemaAST, {
|
|
97
|
+
assumeValid: true,
|
|
98
|
+
assumeValidSDL: true
|
|
99
|
+
});
|
|
100
|
+
`.trim(),
|
|
101
|
+
fromJSON: schemaAST => graphql.buildASTSchema(schemaAST, { assumeValid: true, assumeValidSDL: true }),
|
|
102
|
+
toJSON: schema => utils$1.getDocumentNodeFromSchema(schema),
|
|
103
|
+
validate: async (oldSchema, newSchema) => {
|
|
104
|
+
const changes = await core.diff(oldSchema, newSchema);
|
|
105
|
+
const errors = [];
|
|
106
|
+
for (const change of changes) {
|
|
107
|
+
if (change.criticality.level === core.CriticalityLevel.Breaking ||
|
|
108
|
+
change.criticality.level === core.CriticalityLevel.Dangerous) {
|
|
109
|
+
errors.push(change.message);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (errors.length) {
|
|
113
|
+
if (errors.length === 1) {
|
|
114
|
+
throw errors[0];
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
throw new utils$1.AggregateError(errors);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
},
|
|
86
122
|
};
|
|
87
123
|
class MeshStore {
|
|
88
124
|
constructor(identifier, storage, flags) {
|
package/index.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { path, fs } from '@graphql-mesh/cross-helpers';
|
|
2
2
|
import { writeFile } from '@graphql-mesh/utils';
|
|
3
|
+
import { diff, CriticalityLevel } from '@graphql-inspector/core';
|
|
4
|
+
import { getDocumentNodeFromSchema, AggregateError } from '@graphql-tools/utils';
|
|
5
|
+
import { buildASTSchema } from 'graphql';
|
|
3
6
|
|
|
4
7
|
class ReadonlyStoreError extends Error {
|
|
5
8
|
}
|
|
@@ -66,20 +69,53 @@ var PredefinedProxyOptionsName;
|
|
|
66
69
|
(function (PredefinedProxyOptionsName) {
|
|
67
70
|
PredefinedProxyOptionsName["JsonWithoutValidation"] = "JsonWithoutValidation";
|
|
68
71
|
PredefinedProxyOptionsName["StringWithoutValidation"] = "StringWithoutValidation";
|
|
72
|
+
PredefinedProxyOptionsName["GraphQLSchemaWithDiffing"] = "GraphQLSchemaWithDiffing";
|
|
69
73
|
})(PredefinedProxyOptionsName || (PredefinedProxyOptionsName = {}));
|
|
70
74
|
const PredefinedProxyOptions = {
|
|
71
75
|
JsonWithoutValidation: {
|
|
72
|
-
codify:
|
|
73
|
-
fromJSON:
|
|
74
|
-
toJSON:
|
|
76
|
+
codify: v => `export default ${JSON.stringify(v, null, 2)}`,
|
|
77
|
+
fromJSON: v => v,
|
|
78
|
+
toJSON: v => v,
|
|
75
79
|
validate: () => null,
|
|
76
80
|
},
|
|
77
81
|
StringWithoutValidation: {
|
|
78
|
-
codify:
|
|
79
|
-
fromJSON:
|
|
80
|
-
toJSON:
|
|
82
|
+
codify: v => `export default ${JSON.stringify(v, null, 2)}`,
|
|
83
|
+
fromJSON: v => v,
|
|
84
|
+
toJSON: v => v,
|
|
81
85
|
validate: () => null,
|
|
82
86
|
},
|
|
87
|
+
GraphQLSchemaWithDiffing: {
|
|
88
|
+
codify: schema => `
|
|
89
|
+
import { buildASTSchema } from 'graphql';
|
|
90
|
+
|
|
91
|
+
const schemaAST = ${JSON.stringify(getDocumentNodeFromSchema(schema), null, 2)};
|
|
92
|
+
|
|
93
|
+
export default buildASTSchema(schemaAST, {
|
|
94
|
+
assumeValid: true,
|
|
95
|
+
assumeValidSDL: true
|
|
96
|
+
});
|
|
97
|
+
`.trim(),
|
|
98
|
+
fromJSON: schemaAST => buildASTSchema(schemaAST, { assumeValid: true, assumeValidSDL: true }),
|
|
99
|
+
toJSON: schema => getDocumentNodeFromSchema(schema),
|
|
100
|
+
validate: async (oldSchema, newSchema) => {
|
|
101
|
+
const changes = await diff(oldSchema, newSchema);
|
|
102
|
+
const errors = [];
|
|
103
|
+
for (const change of changes) {
|
|
104
|
+
if (change.criticality.level === CriticalityLevel.Breaking ||
|
|
105
|
+
change.criticality.level === CriticalityLevel.Dangerous) {
|
|
106
|
+
errors.push(change.message);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (errors.length) {
|
|
110
|
+
if (errors.length === 1) {
|
|
111
|
+
throw errors[0];
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
throw new AggregateError(errors);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
},
|
|
83
119
|
};
|
|
84
120
|
class MeshStore {
|
|
85
121
|
constructor(identifier, storage, flags) {
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/store",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha-c34a7d66e.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
+
"@graphql-mesh/types": "0.79.0-alpha-c34a7d66e.0",
|
|
6
7
|
"graphql": "*"
|
|
7
8
|
},
|
|
8
9
|
"dependencies": {
|
|
10
|
+
"@graphql-inspector/core": "3.3.0",
|
|
9
11
|
"@graphql-mesh/cross-helpers": "0.2.0",
|
|
10
|
-
"@graphql-mesh/
|
|
11
|
-
"@graphql-
|
|
12
|
+
"@graphql-mesh/utils": "1.0.0-alpha-c34a7d66e.0",
|
|
13
|
+
"@graphql-tools/utils": "8.8.0",
|
|
12
14
|
"tslib": "^2.4.0"
|
|
13
15
|
},
|
|
14
16
|
"repository": {
|