@ttoss/graphql-api 0.8.7 → 0.8.8
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/dist/esm/index.js +44 -38
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +43 -38
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,12 +1,42 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
4
|
+
value,
|
|
5
|
+
configurable: true
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
// src/buildSchema.ts
|
|
9
|
+
import { applyMiddleware } from "graphql-middleware";
|
|
10
|
+
var buildSchema = /* @__PURE__ */__name(({
|
|
11
|
+
schemaComposer: schemaComposer2,
|
|
12
|
+
middlewares
|
|
13
|
+
}) => {
|
|
14
|
+
if (!schemaComposer2) {
|
|
15
|
+
throw new Error("No schemaComposer provided");
|
|
16
|
+
}
|
|
17
|
+
const schema = schemaComposer2.buildSchema();
|
|
18
|
+
if (middlewares) {
|
|
19
|
+
return applyMiddleware(schema, ...middlewares.map(middleware => {
|
|
20
|
+
if (middleware.generate) {
|
|
21
|
+
return middleware.generate(schema);
|
|
22
|
+
}
|
|
23
|
+
return middleware;
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
return schema;
|
|
27
|
+
}, "buildSchema");
|
|
28
|
+
|
|
29
|
+
// src/composeWithRelay/index.ts
|
|
30
|
+
import { schemaComposer } from "graphql-compose";
|
|
2
31
|
|
|
3
32
|
// src/composeWithRelay/composeWithRelay.ts
|
|
33
|
+
import { toGlobalId } from "@ttoss/ids";
|
|
4
34
|
import { ObjectTypeComposer } from "graphql-compose";
|
|
5
35
|
|
|
6
36
|
// src/composeWithRelay/nodeFieldConfig.ts
|
|
7
|
-
import { getProjectionFromAST } from "graphql-compose";
|
|
8
37
|
import { fromGlobalId } from "@ttoss/ids";
|
|
9
|
-
|
|
38
|
+
import { getProjectionFromAST } from "graphql-compose";
|
|
39
|
+
var getNodeFieldConfig = /* @__PURE__ */__name((typeMapForRelayNode, nodeInterface) => {
|
|
10
40
|
return {
|
|
11
41
|
description: "Fetches an object that has globally unique ID among all types",
|
|
12
42
|
type: nodeInterface,
|
|
@@ -17,7 +47,7 @@ var getNodeFieldConfig = (typeMapForRelayNode, nodeInterface) => {
|
|
|
17
47
|
}
|
|
18
48
|
},
|
|
19
49
|
// eslint-disable-next-line max-params
|
|
20
|
-
resolve: (source, args, context, info) => {
|
|
50
|
+
resolve: /* @__PURE__ */__name((source, args, context, info) => {
|
|
21
51
|
if (!args.id || !(typeof args.id === "string")) {
|
|
22
52
|
return null;
|
|
23
53
|
}
|
|
@@ -48,7 +78,6 @@ var getNodeFieldConfig = (typeMapForRelayNode, nodeInterface) => {
|
|
|
48
78
|
args: {
|
|
49
79
|
[idArgName]: args.id
|
|
50
80
|
},
|
|
51
|
-
// eg. mongoose has _id fieldname, so should map
|
|
52
81
|
context,
|
|
53
82
|
info,
|
|
54
83
|
projection
|
|
@@ -61,9 +90,9 @@ var getNodeFieldConfig = (typeMapForRelayNode, nodeInterface) => {
|
|
|
61
90
|
});
|
|
62
91
|
}
|
|
63
92
|
return null;
|
|
64
|
-
}
|
|
93
|
+
}, "resolve")
|
|
65
94
|
};
|
|
66
|
-
};
|
|
95
|
+
}, "getNodeFieldConfig");
|
|
67
96
|
|
|
68
97
|
// src/composeWithRelay/nodeInterface.ts
|
|
69
98
|
import { InterfaceTypeComposer } from "graphql-compose";
|
|
@@ -76,23 +105,22 @@ var NodeTC = InterfaceTypeComposer.createTemp({
|
|
|
76
105
|
description: "The globally unique ID among all types."
|
|
77
106
|
}
|
|
78
107
|
},
|
|
79
|
-
resolveType: payload => {
|
|
108
|
+
resolveType: /* @__PURE__ */__name(payload => {
|
|
80
109
|
return payload.__nodeType.name ? payload.__nodeType.name : null;
|
|
81
|
-
}
|
|
110
|
+
}, "resolveType")
|
|
82
111
|
});
|
|
83
112
|
var NodeInterface = NodeTC.getType();
|
|
84
|
-
var getNodeInterface = sc => {
|
|
113
|
+
var getNodeInterface = /* @__PURE__ */__name(sc => {
|
|
85
114
|
if (sc.hasInstance("Node", InterfaceTypeComposer)) {
|
|
86
115
|
return sc.get("Node");
|
|
87
116
|
}
|
|
88
117
|
sc.set("Node", NodeTC);
|
|
89
118
|
return NodeTC;
|
|
90
|
-
};
|
|
119
|
+
}, "getNodeInterface");
|
|
91
120
|
|
|
92
121
|
// src/composeWithRelay/composeWithRelay.ts
|
|
93
|
-
import { toGlobalId } from "@ttoss/ids";
|
|
94
122
|
var TypeMapForRelayNode = {};
|
|
95
|
-
var composeWithRelay = tc => {
|
|
123
|
+
var composeWithRelay = /* @__PURE__ */__name(tc => {
|
|
96
124
|
if (!(tc instanceof ObjectTypeComposer)) {
|
|
97
125
|
throw new Error("You should provide ObjectTypeComposer instance to composeWithRelay method");
|
|
98
126
|
}
|
|
@@ -120,41 +148,19 @@ var composeWithRelay = tc => {
|
|
|
120
148
|
id: {
|
|
121
149
|
type: "ID!",
|
|
122
150
|
description: "The globally unique ID among all types",
|
|
123
|
-
resolve: source => {
|
|
151
|
+
resolve: /* @__PURE__ */__name(source => {
|
|
124
152
|
return toGlobalId(tc.getTypeName(), tc.getRecordId(source).toString());
|
|
125
|
-
}
|
|
153
|
+
}, "resolve")
|
|
126
154
|
}
|
|
127
155
|
});
|
|
128
156
|
tc.addInterface(nodeInterface);
|
|
129
157
|
return tc;
|
|
130
|
-
};
|
|
158
|
+
}, "composeWithRelay");
|
|
131
159
|
|
|
132
160
|
// src/composeWithRelay/index.ts
|
|
133
|
-
import { schemaComposer } from "graphql-compose";
|
|
134
161
|
composeWithRelay(schemaComposer.Query);
|
|
135
162
|
|
|
136
163
|
// src/index.ts
|
|
137
|
-
import { composeWithConnection } from "graphql-compose-connection";
|
|
138
164
|
export * from "graphql-compose";
|
|
139
|
-
|
|
140
|
-
// src/buildSchema.ts
|
|
141
|
-
import { applyMiddleware } from "graphql-middleware";
|
|
142
|
-
var buildSchema = ({
|
|
143
|
-
schemaComposer: schemaComposer2,
|
|
144
|
-
middlewares
|
|
145
|
-
}) => {
|
|
146
|
-
if (!schemaComposer2) {
|
|
147
|
-
throw new Error("No schemaComposer provided");
|
|
148
|
-
}
|
|
149
|
-
const schema = schemaComposer2.buildSchema();
|
|
150
|
-
if (middlewares) {
|
|
151
|
-
return applyMiddleware(schema, ...middlewares.map(middleware => {
|
|
152
|
-
if (middleware.generate) {
|
|
153
|
-
return middleware.generate(schema);
|
|
154
|
-
}
|
|
155
|
-
return middleware;
|
|
156
|
-
}));
|
|
157
|
-
}
|
|
158
|
-
return schema;
|
|
159
|
-
};
|
|
165
|
+
import { composeWithConnection } from "graphql-compose-connection";
|
|
160
166
|
export { buildSchema, composeWithConnection, composeWithRelay };
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { ObjectTypeComposer, SchemaComposer } from 'graphql-compose';
|
|
2
|
-
export * from 'graphql-compose';
|
|
3
|
-
export { composeWithConnection } from 'graphql-compose-connection';
|
|
4
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
|
+
import { SchemaComposer, ObjectTypeComposer } from 'graphql-compose';
|
|
3
|
+
export * from 'graphql-compose';
|
|
5
4
|
import { IMiddleware, IMiddlewareGenerator } from 'graphql-middleware';
|
|
6
5
|
export { IMiddleware as Middleware } from 'graphql-middleware';
|
|
7
|
-
|
|
8
|
-
declare const composeWithRelay: <TContext>(tc: ObjectTypeComposer<any, TContext>) => ObjectTypeComposer<any, TContext>;
|
|
6
|
+
export { composeWithConnection } from 'graphql-compose-connection';
|
|
9
7
|
|
|
10
8
|
type BuildSchemaInput<TContext = unknown> = {
|
|
11
9
|
schemaComposer: SchemaComposer<TContext>;
|
|
@@ -13,4 +11,6 @@ type BuildSchemaInput<TContext = unknown> = {
|
|
|
13
11
|
};
|
|
14
12
|
declare const buildSchema: ({ schemaComposer, middlewares, }: BuildSchemaInput) => GraphQLSchema;
|
|
15
13
|
|
|
14
|
+
declare const composeWithRelay: <TContext>(tc: ObjectTypeComposer<any, TContext>) => ObjectTypeComposer<any, TContext>;
|
|
15
|
+
|
|
16
16
|
export { type BuildSchemaInput, buildSchema, composeWithRelay };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { ObjectTypeComposer, SchemaComposer } from 'graphql-compose';
|
|
2
|
-
export * from 'graphql-compose';
|
|
3
|
-
export { composeWithConnection } from 'graphql-compose-connection';
|
|
4
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
|
+
import { SchemaComposer, ObjectTypeComposer } from 'graphql-compose';
|
|
3
|
+
export * from 'graphql-compose';
|
|
5
4
|
import { IMiddleware, IMiddlewareGenerator } from 'graphql-middleware';
|
|
6
5
|
export { IMiddleware as Middleware } from 'graphql-middleware';
|
|
7
|
-
|
|
8
|
-
declare const composeWithRelay: <TContext>(tc: ObjectTypeComposer<any, TContext>) => ObjectTypeComposer<any, TContext>;
|
|
6
|
+
export { composeWithConnection } from 'graphql-compose-connection';
|
|
9
7
|
|
|
10
8
|
type BuildSchemaInput<TContext = unknown> = {
|
|
11
9
|
schemaComposer: SchemaComposer<TContext>;
|
|
@@ -13,4 +11,6 @@ type BuildSchemaInput<TContext = unknown> = {
|
|
|
13
11
|
};
|
|
14
12
|
declare const buildSchema: ({ schemaComposer, middlewares, }: BuildSchemaInput) => GraphQLSchema;
|
|
15
13
|
|
|
14
|
+
declare const composeWithRelay: <TContext>(tc: ObjectTypeComposer<any, TContext>) => ObjectTypeComposer<any, TContext>;
|
|
15
|
+
|
|
16
16
|
export { type BuildSchemaInput, buildSchema, composeWithRelay };
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,10 @@ var __defProp = Object.defineProperty;
|
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
9
|
+
value,
|
|
10
|
+
configurable: true
|
|
11
|
+
});
|
|
8
12
|
var __export = (target, all) => {
|
|
9
13
|
for (var name in all) __defProp(target, name, {
|
|
10
14
|
get: all[name],
|
|
@@ -34,13 +38,38 @@ __export(index_exports, {
|
|
|
34
38
|
});
|
|
35
39
|
module.exports = __toCommonJS(index_exports);
|
|
36
40
|
|
|
41
|
+
// src/buildSchema.ts
|
|
42
|
+
var import_graphql_middleware = require("graphql-middleware");
|
|
43
|
+
var buildSchema = /* @__PURE__ */__name(({
|
|
44
|
+
schemaComposer: schemaComposer2,
|
|
45
|
+
middlewares
|
|
46
|
+
}) => {
|
|
47
|
+
if (!schemaComposer2) {
|
|
48
|
+
throw new Error("No schemaComposer provided");
|
|
49
|
+
}
|
|
50
|
+
const schema = schemaComposer2.buildSchema();
|
|
51
|
+
if (middlewares) {
|
|
52
|
+
return (0, import_graphql_middleware.applyMiddleware)(schema, ...middlewares.map(middleware => {
|
|
53
|
+
if (middleware.generate) {
|
|
54
|
+
return middleware.generate(schema);
|
|
55
|
+
}
|
|
56
|
+
return middleware;
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
return schema;
|
|
60
|
+
}, "buildSchema");
|
|
61
|
+
|
|
62
|
+
// src/composeWithRelay/index.ts
|
|
63
|
+
var import_graphql_compose4 = require("graphql-compose");
|
|
64
|
+
|
|
37
65
|
// src/composeWithRelay/composeWithRelay.ts
|
|
66
|
+
var import_ids2 = require("@ttoss/ids");
|
|
38
67
|
var import_graphql_compose3 = require("graphql-compose");
|
|
39
68
|
|
|
40
69
|
// src/composeWithRelay/nodeFieldConfig.ts
|
|
41
|
-
var import_graphql_compose = require("graphql-compose");
|
|
42
70
|
var import_ids = require("@ttoss/ids");
|
|
43
|
-
var
|
|
71
|
+
var import_graphql_compose = require("graphql-compose");
|
|
72
|
+
var getNodeFieldConfig = /* @__PURE__ */__name((typeMapForRelayNode, nodeInterface) => {
|
|
44
73
|
return {
|
|
45
74
|
description: "Fetches an object that has globally unique ID among all types",
|
|
46
75
|
type: nodeInterface,
|
|
@@ -51,7 +80,7 @@ var getNodeFieldConfig = (typeMapForRelayNode, nodeInterface) => {
|
|
|
51
80
|
}
|
|
52
81
|
},
|
|
53
82
|
// eslint-disable-next-line max-params
|
|
54
|
-
resolve: (source, args, context, info) => {
|
|
83
|
+
resolve: /* @__PURE__ */__name((source, args, context, info) => {
|
|
55
84
|
if (!args.id || !(typeof args.id === "string")) {
|
|
56
85
|
return null;
|
|
57
86
|
}
|
|
@@ -82,7 +111,6 @@ var getNodeFieldConfig = (typeMapForRelayNode, nodeInterface) => {
|
|
|
82
111
|
args: {
|
|
83
112
|
[idArgName]: args.id
|
|
84
113
|
},
|
|
85
|
-
// eg. mongoose has _id fieldname, so should map
|
|
86
114
|
context,
|
|
87
115
|
info,
|
|
88
116
|
projection
|
|
@@ -95,9 +123,9 @@ var getNodeFieldConfig = (typeMapForRelayNode, nodeInterface) => {
|
|
|
95
123
|
});
|
|
96
124
|
}
|
|
97
125
|
return null;
|
|
98
|
-
}
|
|
126
|
+
}, "resolve")
|
|
99
127
|
};
|
|
100
|
-
};
|
|
128
|
+
}, "getNodeFieldConfig");
|
|
101
129
|
|
|
102
130
|
// src/composeWithRelay/nodeInterface.ts
|
|
103
131
|
var import_graphql_compose2 = require("graphql-compose");
|
|
@@ -110,23 +138,22 @@ var NodeTC = import_graphql_compose2.InterfaceTypeComposer.createTemp({
|
|
|
110
138
|
description: "The globally unique ID among all types."
|
|
111
139
|
}
|
|
112
140
|
},
|
|
113
|
-
resolveType: payload => {
|
|
141
|
+
resolveType: /* @__PURE__ */__name(payload => {
|
|
114
142
|
return payload.__nodeType.name ? payload.__nodeType.name : null;
|
|
115
|
-
}
|
|
143
|
+
}, "resolveType")
|
|
116
144
|
});
|
|
117
145
|
var NodeInterface = NodeTC.getType();
|
|
118
|
-
var getNodeInterface = sc => {
|
|
146
|
+
var getNodeInterface = /* @__PURE__ */__name(sc => {
|
|
119
147
|
if (sc.hasInstance("Node", import_graphql_compose2.InterfaceTypeComposer)) {
|
|
120
148
|
return sc.get("Node");
|
|
121
149
|
}
|
|
122
150
|
sc.set("Node", NodeTC);
|
|
123
151
|
return NodeTC;
|
|
124
|
-
};
|
|
152
|
+
}, "getNodeInterface");
|
|
125
153
|
|
|
126
154
|
// src/composeWithRelay/composeWithRelay.ts
|
|
127
|
-
var import_ids2 = require("@ttoss/ids");
|
|
128
155
|
var TypeMapForRelayNode = {};
|
|
129
|
-
var composeWithRelay = tc => {
|
|
156
|
+
var composeWithRelay = /* @__PURE__ */__name(tc => {
|
|
130
157
|
if (!(tc instanceof import_graphql_compose3.ObjectTypeComposer)) {
|
|
131
158
|
throw new Error("You should provide ObjectTypeComposer instance to composeWithRelay method");
|
|
132
159
|
}
|
|
@@ -154,43 +181,21 @@ var composeWithRelay = tc => {
|
|
|
154
181
|
id: {
|
|
155
182
|
type: "ID!",
|
|
156
183
|
description: "The globally unique ID among all types",
|
|
157
|
-
resolve: source => {
|
|
184
|
+
resolve: /* @__PURE__ */__name(source => {
|
|
158
185
|
return (0, import_ids2.toGlobalId)(tc.getTypeName(), tc.getRecordId(source).toString());
|
|
159
|
-
}
|
|
186
|
+
}, "resolve")
|
|
160
187
|
}
|
|
161
188
|
});
|
|
162
189
|
tc.addInterface(nodeInterface);
|
|
163
190
|
return tc;
|
|
164
|
-
};
|
|
191
|
+
}, "composeWithRelay");
|
|
165
192
|
|
|
166
193
|
// src/composeWithRelay/index.ts
|
|
167
|
-
var import_graphql_compose4 = require("graphql-compose");
|
|
168
194
|
composeWithRelay(import_graphql_compose4.schemaComposer.Query);
|
|
169
195
|
|
|
170
196
|
// src/index.ts
|
|
171
|
-
var import_graphql_compose_connection = require("graphql-compose-connection");
|
|
172
197
|
__reExport(index_exports, require("graphql-compose"), module.exports);
|
|
173
|
-
|
|
174
|
-
// src/buildSchema.ts
|
|
175
|
-
var import_graphql_middleware = require("graphql-middleware");
|
|
176
|
-
var buildSchema = ({
|
|
177
|
-
schemaComposer: schemaComposer2,
|
|
178
|
-
middlewares
|
|
179
|
-
}) => {
|
|
180
|
-
if (!schemaComposer2) {
|
|
181
|
-
throw new Error("No schemaComposer provided");
|
|
182
|
-
}
|
|
183
|
-
const schema = schemaComposer2.buildSchema();
|
|
184
|
-
if (middlewares) {
|
|
185
|
-
return (0, import_graphql_middleware.applyMiddleware)(schema, ...middlewares.map(middleware => {
|
|
186
|
-
if (middleware.generate) {
|
|
187
|
-
return middleware.generate(schema);
|
|
188
|
-
}
|
|
189
|
-
return middleware;
|
|
190
|
-
}));
|
|
191
|
-
}
|
|
192
|
-
return schema;
|
|
193
|
-
};
|
|
198
|
+
var import_graphql_compose_connection = require("graphql-compose-connection");
|
|
194
199
|
// Annotate the CommonJS export names for ESM import in node:
|
|
195
200
|
0 && (module.exports = {
|
|
196
201
|
buildSchema,
|