@orion-js/graphql 4.3.1 → 4.4.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/LICENSE +21 -0
- package/dist/buildSchema/getArgs/getField.d.ts +7 -0
- package/dist/buildSchema/getArgs/index.d.ts +3 -0
- package/dist/buildSchema/getMutation.d.ts +3 -0
- package/dist/buildSchema/getQuery.d.ts +3 -0
- package/dist/buildSchema/getResolvers/index.d.ts +3 -0
- package/dist/buildSchema/getResolvers/resolversStore.d.ts +3 -0
- package/dist/buildSchema/getSubscription.d.ts +3 -0
- package/dist/buildSchema/getSubscriptions/index.d.ts +2 -0
- package/dist/buildSchema/getType/BigIntScalar.d.ts +3 -0
- package/dist/buildSchema/getType/DateScalar.d.ts +3 -0
- package/dist/buildSchema/getType/JSONScalar.d.ts +3 -0
- package/dist/buildSchema/getType/getScalar.d.ts +1 -0
- package/dist/buildSchema/getType/getTypeAsResolver.d.ts +10 -0
- package/dist/buildSchema/getType/index.d.ts +6 -0
- package/dist/buildSchema/index.d.ts +3 -0
- package/dist/errorHandler.d.ts +1 -0
- package/dist/getApolloOptions/formatError.d.ts +1 -0
- package/dist/getApolloOptions/index.d.ts +3 -0
- package/dist/index.cjs +36 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +13 -172
- package/dist/index.js +35 -32
- package/dist/index.js.map +1 -1
- package/dist/pubsub.d.ts +3 -0
- package/dist/resolversSchemas/ResolverParamsInfo.d.ts +15 -0
- package/dist/resolversSchemas/getBasicResultQuery.d.ts +2 -0
- package/dist/resolversSchemas/getDynamicFields.d.ts +2 -0
- package/dist/resolversSchemas/getField.d.ts +2 -0
- package/dist/resolversSchemas/getModelLoadedResolvers.d.ts +3 -0
- package/dist/resolversSchemas/getStaticFields.d.ts +2 -0
- package/dist/resolversSchemas/index.d.ts +11 -0
- package/dist/resolversSchemas/params.d.ts +10 -0
- package/dist/resolversSchemas/serializeSchema.d.ts +2 -0
- package/dist/service/global.d.ts +15 -0
- package/dist/service/index.d.ts +4 -0
- package/dist/service/middlewares.d.ts +6 -0
- package/dist/service/model.d.ts +13 -0
- package/dist/service/subscription.d.ts +6 -0
- package/dist/startGraphQL.d.ts +2 -0
- package/dist/startGraphiQL.d.ts +3 -0
- package/dist/startWebsocket.d.ts +11 -0
- package/dist/subscription/getChannelName.d.ts +1 -0
- package/dist/subscription/index.d.ts +3 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/startGraphQL.d.ts +51 -0
- package/dist/types/subscription.d.ts +23 -0
- package/dist/websockerViewer.d.ts +2 -0
- package/package.json +19 -20
- package/dist/index.d.cts +0 -172
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Orionjs Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GraphQLInputObjectType } from 'graphql';
|
|
2
|
+
import { Schema } from '@orion-js/schema';
|
|
3
|
+
import { StartGraphQLOptions } from '../../types';
|
|
4
|
+
export declare function clearRegisteredGraphQLInputTypes(): void;
|
|
5
|
+
declare const resolveType: (type: any, options: StartGraphQLOptions) => any;
|
|
6
|
+
export default resolveType;
|
|
7
|
+
export declare const createGraphQLInputType: (modelName: string, schema: Schema, options: StartGraphQLOptions) => GraphQLInputObjectType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (fieldType: any): any;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { GraphQLObjectType } from 'graphql';
|
|
2
|
+
import { Schema, SchemaFieldType } from '@orion-js/schema';
|
|
3
|
+
import { StartGraphQLOptions } from '../../types/startGraphQL';
|
|
4
|
+
export declare const createGraphQLObjectType: (modelName: string, schema: Schema, options: StartGraphQLOptions) => GraphQLObjectType<any, any>;
|
|
5
|
+
export declare function clearRegisteredGraphQLTypes(): void;
|
|
6
|
+
export default function getGraphQLType(type: SchemaFieldType, options: StartGraphQLOptions): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function errorHandler(error: any, data: any): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (apolloError: any): any;
|
package/dist/index.cjs
CHANGED
|
@@ -827,14 +827,16 @@ function getDynamicFields(schema) {
|
|
|
827
827
|
// src/resolversSchemas/getModelLoadedResolvers.ts
|
|
828
828
|
function getModelLoadedResolvers(schema, options) {
|
|
829
829
|
if (!options.modelResolvers) return [];
|
|
830
|
+
if (!schema.__modelName) return [];
|
|
830
831
|
const resolvers = options.modelResolvers[schema.__modelName];
|
|
831
832
|
if (!resolvers) return [];
|
|
832
833
|
const keys = Object.keys(resolvers);
|
|
833
834
|
return keys.map((key) => {
|
|
834
835
|
const resolver = resolvers[key];
|
|
835
|
-
|
|
836
|
+
const namedResolver = resolver;
|
|
837
|
+
namedResolver.resolverName = key;
|
|
836
838
|
return {
|
|
837
|
-
...
|
|
839
|
+
...namedResolver,
|
|
838
840
|
key
|
|
839
841
|
};
|
|
840
842
|
}).filter((resolver) => !resolver.private);
|
|
@@ -1153,12 +1155,35 @@ async function startGraphQL_default(options) {
|
|
|
1153
1155
|
}
|
|
1154
1156
|
|
|
1155
1157
|
// src/resolversSchemas/params.ts
|
|
1156
|
-
var import_resolvers = require("@orion-js/resolvers");
|
|
1157
1158
|
var import_helpers2 = require("@orion-js/helpers");
|
|
1159
|
+
var import_resolvers = require("@orion-js/resolvers");
|
|
1160
|
+
var import_schema8 = require("@orion-js/schema");
|
|
1158
1161
|
|
|
1159
|
-
// src/resolversSchemas/
|
|
1162
|
+
// src/resolversSchemas/getBasicResultQuery.ts
|
|
1160
1163
|
var import_schema4 = require("@orion-js/schema");
|
|
1161
|
-
|
|
1164
|
+
async function getBasicQuery(field) {
|
|
1165
|
+
if (!field.type) return "";
|
|
1166
|
+
if (Array.isArray(field.type)) {
|
|
1167
|
+
return getBasicQuery({
|
|
1168
|
+
...field,
|
|
1169
|
+
type: field.type[0]
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
if (!(0, import_schema4.isSchemaLike)(field.type)) {
|
|
1173
|
+
return field.key;
|
|
1174
|
+
}
|
|
1175
|
+
const schema = (0, import_schema4.getSchemaFromAnyOrionForm)(field.type);
|
|
1176
|
+
const fields = [];
|
|
1177
|
+
for (const field2 of getStaticFields(schema)) {
|
|
1178
|
+
fields.push(await getBasicQuery(field2));
|
|
1179
|
+
}
|
|
1180
|
+
const key = field.key ? `${field.key} ` : "";
|
|
1181
|
+
return `${key}{ ${fields.join(" ")} }`;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
// src/resolversSchemas/ResolverParamsInfo.ts
|
|
1185
|
+
var import_schema5 = require("@orion-js/schema");
|
|
1186
|
+
var ResolverParamsInfo_default = (0, import_schema5.schemaWithName)("ResolverParams", {
|
|
1162
1187
|
name: {
|
|
1163
1188
|
type: "string"
|
|
1164
1189
|
},
|
|
@@ -1174,10 +1199,10 @@ var ResolverParamsInfo_default = (0, import_schema4.schemaWithName)("ResolverPar
|
|
|
1174
1199
|
});
|
|
1175
1200
|
|
|
1176
1201
|
// src/resolversSchemas/serializeSchema.ts
|
|
1177
|
-
var
|
|
1202
|
+
var import_schema7 = require("@orion-js/schema");
|
|
1178
1203
|
|
|
1179
1204
|
// src/resolversSchemas/getField.ts
|
|
1180
|
-
var
|
|
1205
|
+
var import_schema6 = require("@orion-js/schema");
|
|
1181
1206
|
async function getParams(field) {
|
|
1182
1207
|
const { type: type2 } = field;
|
|
1183
1208
|
if (Array.isArray(type2)) {
|
|
@@ -1188,9 +1213,9 @@ async function getParams(field) {
|
|
|
1188
1213
|
__graphQLType: `[${serialized.__graphQLType}]`
|
|
1189
1214
|
};
|
|
1190
1215
|
}
|
|
1191
|
-
const isSchema = (0,
|
|
1216
|
+
const isSchema = (0, import_schema6.isSchemaLike)(type2);
|
|
1192
1217
|
if (isSchema) {
|
|
1193
|
-
const schemaOfType = (0,
|
|
1218
|
+
const schemaOfType = (0, import_schema6.getSchemaWithMetadataFromAnyOrionForm)(type2);
|
|
1194
1219
|
const modelName = schemaOfType.__modelName;
|
|
1195
1220
|
if (!modelName) {
|
|
1196
1221
|
throw new Error("The schema needs a model name to be serialized for GraphQL");
|
|
@@ -1205,7 +1230,7 @@ async function getParams(field) {
|
|
|
1205
1230
|
__graphQLType: `${modelName}Input`
|
|
1206
1231
|
};
|
|
1207
1232
|
}
|
|
1208
|
-
const schemaType = (0,
|
|
1233
|
+
const schemaType = (0, import_schema6.getFieldType)(type2);
|
|
1209
1234
|
const graphQLType = await getScalar_default(schemaType);
|
|
1210
1235
|
const withoutKey = isType("Object", field) ? omit(["key"], field) : {};
|
|
1211
1236
|
return {
|
|
@@ -1218,7 +1243,7 @@ async function getParams(field) {
|
|
|
1218
1243
|
// src/resolversSchemas/serializeSchema.ts
|
|
1219
1244
|
async function serializeSchema(params) {
|
|
1220
1245
|
if (!params) return;
|
|
1221
|
-
const schema = (0,
|
|
1246
|
+
const schema = (0, import_schema7.getSchemaFromAnyOrionForm)(params);
|
|
1222
1247
|
if (Object.keys(schema).length === 0) return;
|
|
1223
1248
|
const fields = {};
|
|
1224
1249
|
for (const key of Object.keys(schema).filter((key2) => !key2.startsWith("__"))) {
|
|
@@ -1232,31 +1257,6 @@ async function serializeSchema(params) {
|
|
|
1232
1257
|
return fields;
|
|
1233
1258
|
}
|
|
1234
1259
|
|
|
1235
|
-
// src/resolversSchemas/params.ts
|
|
1236
|
-
var import_schema8 = require("@orion-js/schema");
|
|
1237
|
-
|
|
1238
|
-
// src/resolversSchemas/getBasicResultQuery.ts
|
|
1239
|
-
var import_schema7 = require("@orion-js/schema");
|
|
1240
|
-
async function getBasicQuery(field) {
|
|
1241
|
-
if (!field.type) return "";
|
|
1242
|
-
if (Array.isArray(field.type)) {
|
|
1243
|
-
return getBasicQuery({
|
|
1244
|
-
...field,
|
|
1245
|
-
type: field.type[0]
|
|
1246
|
-
});
|
|
1247
|
-
}
|
|
1248
|
-
if (!(0, import_schema7.isSchemaLike)(field.type)) {
|
|
1249
|
-
return field.key;
|
|
1250
|
-
}
|
|
1251
|
-
const schema = (0, import_schema7.getSchemaFromAnyOrionForm)(field.type);
|
|
1252
|
-
const fields = [];
|
|
1253
|
-
for (const field2 of getStaticFields(schema)) {
|
|
1254
|
-
fields.push(await getBasicQuery(field2));
|
|
1255
|
-
}
|
|
1256
|
-
const key = field.key ? `${field.key} ` : "";
|
|
1257
|
-
return `${key}{ ${fields.join(" ")} }`;
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
1260
|
// src/resolversSchemas/params.ts
|
|
1261
1261
|
function getResultTypeName(type2) {
|
|
1262
1262
|
const returns = Array.isArray(type2) ? type2[0] : type2;
|