@orion-js/graphql 4.3.2 → 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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/dist/buildSchema/getArgs/getField.d.ts +7 -0
  3. package/dist/buildSchema/getArgs/index.d.ts +3 -0
  4. package/dist/buildSchema/getMutation.d.ts +3 -0
  5. package/dist/buildSchema/getQuery.d.ts +3 -0
  6. package/dist/buildSchema/getResolvers/index.d.ts +3 -0
  7. package/dist/buildSchema/getResolvers/resolversStore.d.ts +3 -0
  8. package/dist/buildSchema/getSubscription.d.ts +3 -0
  9. package/dist/buildSchema/getSubscriptions/index.d.ts +2 -0
  10. package/dist/buildSchema/getType/BigIntScalar.d.ts +3 -0
  11. package/dist/buildSchema/getType/DateScalar.d.ts +3 -0
  12. package/dist/buildSchema/getType/JSONScalar.d.ts +3 -0
  13. package/dist/buildSchema/getType/getScalar.d.ts +1 -0
  14. package/dist/buildSchema/getType/getTypeAsResolver.d.ts +10 -0
  15. package/dist/buildSchema/getType/index.d.ts +6 -0
  16. package/dist/buildSchema/index.d.ts +3 -0
  17. package/dist/errorHandler.d.ts +1 -0
  18. package/dist/getApolloOptions/formatError.d.ts +1 -0
  19. package/dist/getApolloOptions/index.d.ts +3 -0
  20. package/dist/index.cjs +36 -36
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.ts +13 -172
  23. package/dist/index.js +35 -32
  24. package/dist/index.js.map +1 -1
  25. package/dist/pubsub.d.ts +3 -0
  26. package/dist/resolversSchemas/ResolverParamsInfo.d.ts +15 -0
  27. package/dist/resolversSchemas/getBasicResultQuery.d.ts +2 -0
  28. package/dist/resolversSchemas/getDynamicFields.d.ts +2 -0
  29. package/dist/resolversSchemas/getField.d.ts +2 -0
  30. package/dist/resolversSchemas/getModelLoadedResolvers.d.ts +3 -0
  31. package/dist/resolversSchemas/getStaticFields.d.ts +2 -0
  32. package/dist/resolversSchemas/index.d.ts +11 -0
  33. package/dist/resolversSchemas/params.d.ts +10 -0
  34. package/dist/resolversSchemas/serializeSchema.d.ts +2 -0
  35. package/dist/service/global.d.ts +15 -0
  36. package/dist/service/index.d.ts +4 -0
  37. package/dist/service/middlewares.d.ts +6 -0
  38. package/dist/service/model.d.ts +13 -0
  39. package/dist/service/subscription.d.ts +6 -0
  40. package/dist/startGraphQL.d.ts +2 -0
  41. package/dist/startGraphiQL.d.ts +3 -0
  42. package/dist/startWebsocket.d.ts +11 -0
  43. package/dist/subscription/getChannelName.d.ts +1 -0
  44. package/dist/subscription/index.d.ts +3 -0
  45. package/dist/types/index.d.ts +3 -0
  46. package/dist/types/startGraphQL.d.ts +51 -0
  47. package/dist/types/subscription.d.ts +23 -0
  48. package/dist/websockerViewer.d.ts +2 -0
  49. package/package.json +19 -20
  50. 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,3 @@
1
+ import { Schema } from '@orion-js/schema';
2
+ import { StartGraphQLOptions } from '../../types';
3
+ export default function (params: Schema, options: StartGraphQLOptions): {};
@@ -0,0 +1,3 @@
1
+ import { GraphQLObjectType } from 'graphql';
2
+ import { StartGraphQLOptions } from '../types/startGraphQL';
3
+ export default function (options: StartGraphQLOptions): Promise<GraphQLObjectType<any, any>>;
@@ -0,0 +1,3 @@
1
+ import { GraphQLObjectType } from 'graphql';
2
+ import { StartGraphQLOptions } from '../types/startGraphQL';
3
+ export default function (options: StartGraphQLOptions): Promise<GraphQLObjectType<any, any>>;
@@ -0,0 +1,3 @@
1
+ import { GraphQLFieldConfig } from 'graphql';
2
+ import { StartGraphQLOptions } from '../../types/startGraphQL';
3
+ export default function (options: StartGraphQLOptions, mutation: boolean): Promise<import("graphql/jsutils/ObjMap").ObjMap<GraphQLFieldConfig<any, any, any>>>;
@@ -0,0 +1,3 @@
1
+ import { GlobalResolversMap } from '@orion-js/models';
2
+ declare const resolversStore: GlobalResolversMap;
3
+ export { resolversStore };
@@ -0,0 +1,3 @@
1
+ import { GraphQLObjectType } from 'graphql';
2
+ import { StartGraphQLOptions } from '../types/startGraphQL';
3
+ export default function (options: StartGraphQLOptions): Promise<GraphQLObjectType>;
@@ -0,0 +1,2 @@
1
+ import { StartGraphQLOptions } from '../../types/startGraphQL';
2
+ export default function (options: StartGraphQLOptions): Promise<{}>;
@@ -0,0 +1,3 @@
1
+ import { GraphQLScalarType } from 'graphql';
2
+ declare const _default: GraphQLScalarType<number, number>;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { GraphQLScalarType } from 'graphql';
2
+ declare const _default: GraphQLScalarType<Date, Date>;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { GraphQLScalarType } from 'graphql';
2
+ declare const _default: GraphQLScalarType<any, any>;
3
+ export default _default;
@@ -0,0 +1 @@
1
+ export default function (fieldType: any): any;
@@ -0,0 +1,10 @@
1
+ export default function ({ resolver, getGraphQLType, options, schema }: {
2
+ getGraphQLType: any;
3
+ options: any;
4
+ resolver: any;
5
+ schema: any;
6
+ }): {
7
+ type: any;
8
+ args: {};
9
+ resolve(item: any, params: any, context: any, info: any): Promise<any>;
10
+ };
@@ -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,3 @@
1
+ import { GraphQLSchema } from 'graphql';
2
+ import { StartGraphQLOptions } from '../types/startGraphQL';
3
+ export default function (options: StartGraphQLOptions): Promise<GraphQLSchema>;
@@ -0,0 +1 @@
1
+ export default function errorHandler(error: any, data: any): void;
@@ -0,0 +1 @@
1
+ export default function (apolloError: any): any;
@@ -0,0 +1,3 @@
1
+ import { StartGraphQLOptions } from '../types/startGraphQL';
2
+ import { ApolloServerOptions } from '@apollo/server';
3
+ export default function (options: StartGraphQLOptions): Promise<ApolloServerOptions<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
- resolver.resolverName = key;
836
+ const namedResolver = resolver;
837
+ namedResolver.resolverName = key;
836
838
  return {
837
- ...resolver,
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/ResolverParamsInfo.ts
1162
+ // src/resolversSchemas/getBasicResultQuery.ts
1160
1163
  var import_schema4 = require("@orion-js/schema");
1161
- var ResolverParamsInfo_default = (0, import_schema4.schemaWithName)("ResolverParams", {
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 import_schema6 = require("@orion-js/schema");
1202
+ var import_schema7 = require("@orion-js/schema");
1178
1203
 
1179
1204
  // src/resolversSchemas/getField.ts
1180
- var import_schema5 = require("@orion-js/schema");
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, import_schema5.isSchemaLike)(type2);
1216
+ const isSchema = (0, import_schema6.isSchemaLike)(type2);
1192
1217
  if (isSchema) {
1193
- const schemaOfType = (0, import_schema5.getSchemaWithMetadataFromAnyOrionForm)(type2);
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, import_schema5.getFieldType)(type2);
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, import_schema6.getSchemaFromAnyOrionForm)(params);
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;