sofa-api 0.11.1 → 0.11.2

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.js CHANGED
@@ -11,7 +11,7 @@ const utils = require('@graphql-tools/utils');
11
11
  const paramCase = require('param-case');
12
12
  const uuid = require('uuid');
13
13
  const crossUndiciFetch = require('cross-undici-fetch');
14
- const colors = require('ansi-colors');
14
+ const colors = _interopDefault(require('ansi-colors'));
15
15
  const jsYaml = require('js-yaml');
16
16
  const fs = require('fs');
17
17
  const titleCase = require('title-case');
@@ -566,24 +566,8 @@ function extractsModels(schema) {
566
566
  }
567
567
  // it's dumb but let's leave it for now
568
568
  function isArrayOf(type, expected) {
569
- if (isOptionalList(type)) {
570
- return true;
571
- }
572
- if (graphql.isNonNullType(type) && isOptionalList(type.ofType)) {
573
- return true;
574
- }
575
- function isOptionalList(list) {
576
- if (graphql.isListType(list)) {
577
- if (list.ofType.name === expected.name) {
578
- return true;
579
- }
580
- if (graphql.isNonNullType(list.ofType) &&
581
- list.ofType.ofType.name === expected.name) {
582
- return true;
583
- }
584
- }
585
- }
586
- return false;
569
+ const typeNameInSdl = type.toString();
570
+ return (typeNameInSdl.includes('[') && typeNameInSdl.includes(expected.toString()));
587
571
  }
588
572
  function hasID(type) {
589
573
  return graphql.isObjectType(type) && !!type.getFields().id;
package/index.mjs CHANGED
@@ -5,7 +5,7 @@ import { buildOperationNodeForField } from '@graphql-tools/utils';
5
5
  import { paramCase } from 'param-case';
6
6
  import { v4 } from 'uuid';
7
7
  import { fetch } from 'cross-undici-fetch';
8
- import { red, yellow, green, blue } from 'ansi-colors';
8
+ import colors from 'ansi-colors';
9
9
  import { dump } from 'js-yaml';
10
10
  import { writeFileSync } from 'fs';
11
11
  import { titleCase } from 'title-case';
@@ -84,16 +84,16 @@ const log = (level, color, args) => {
84
84
  };
85
85
  const logger = {
86
86
  error: (...args) => {
87
- log('error', red, args);
87
+ log('error', colors.red, args);
88
88
  },
89
89
  warn: (...args) => {
90
- log('warn', yellow, args);
90
+ log('warn', colors.yellow, args);
91
91
  },
92
92
  info: (...args) => {
93
- log('info', green, args);
93
+ log('info', colors.green, args);
94
94
  },
95
95
  debug: (...args) => {
96
- log('debug', blue, args);
96
+ log('debug', colors.blue, args);
97
97
  },
98
98
  };
99
99
 
@@ -560,24 +560,8 @@ function extractsModels(schema) {
560
560
  }
561
561
  // it's dumb but let's leave it for now
562
562
  function isArrayOf(type, expected) {
563
- if (isOptionalList(type)) {
564
- return true;
565
- }
566
- if (isNonNullType(type) && isOptionalList(type.ofType)) {
567
- return true;
568
- }
569
- function isOptionalList(list) {
570
- if (isListType(list)) {
571
- if (list.ofType.name === expected.name) {
572
- return true;
573
- }
574
- if (isNonNullType(list.ofType) &&
575
- list.ofType.ofType.name === expected.name) {
576
- return true;
577
- }
578
- }
579
- }
580
- return false;
563
+ const typeNameInSdl = type.toString();
564
+ return (typeNameInSdl.includes('[') && typeNameInSdl.includes(expected.toString()));
581
565
  }
582
566
  function hasID(type) {
583
567
  return isObjectType(type) && !!type.getFields().id;
@@ -1,3 +1,3 @@
1
- import { GraphQLObjectType, GraphQLInputObjectType, GraphQLOutputType, GraphQLNamedType } from 'graphql';
1
+ import { GraphQLObjectType, GraphQLInputObjectType, GraphQLType } from 'graphql';
2
2
  export declare function buildSchemaObjectFromType(type: GraphQLObjectType | GraphQLInputObjectType): any;
3
- export declare function resolveFieldType(type: GraphQLOutputType | GraphQLNamedType): any;
3
+ export declare function resolveFieldType(type: GraphQLType): any;
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "sofa-api",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "description": "Create REST APIs with GraphQL",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
- "graphql": "^0.13.2 || ^14.0.0 || ^15.0.0"
7
+ "graphql": "^0.13.2 || ^14.0.0 || ^15.0.0 || ^16.0.0"
8
8
  },
9
9
  "dependencies": {
10
- "@graphql-tools/utils": "8.1.1",
11
- "@types/js-yaml": "4.0.2",
10
+ "@graphql-tools/utils": "8.6.5",
11
+ "@types/js-yaml": "4.0.5",
12
12
  "ansi-colors": "4.1.1",
13
13
  "cross-undici-fetch": "0.1.28",
14
14
  "js-yaml": "4.1.0",
@@ -48,6 +48,7 @@
48
48
  "./*": {
49
49
  "require": "./*.js",
50
50
  "import": "./*.mjs"
51
- }
51
+ },
52
+ "./package.json": "./package.json"
52
53
  }
53
54
  }
@@ -20,19 +20,11 @@ export declare class SubscriptionManager {
20
20
  private operations;
21
21
  private clients;
22
22
  constructor(sofa: Sofa);
23
- start(event: StartSubscriptionEvent, contextValue: ContextValue): Promise<ExecutionResult<{
24
- [key: string]: any;
25
- }, {
26
- [key: string]: any;
27
- }> | {
23
+ start(event: StartSubscriptionEvent, contextValue: ContextValue): Promise<ExecutionResult<import("graphql/jsutils/ObjMap").ObjMap<unknown>, import("graphql/jsutils/ObjMap").ObjMap<unknown>> | {
28
24
  id: string;
29
25
  }>;
30
26
  stop(id: ID): Promise<StopSubscriptionResponse>;
31
- update(event: UpdateSubscriptionEvent, contextValue: ContextValue): Promise<ExecutionResult<{
32
- [key: string]: any;
33
- }, {
34
- [key: string]: any;
35
- }> | {
27
+ update(event: UpdateSubscriptionEvent, contextValue: ContextValue): Promise<ExecutionResult<import("graphql/jsutils/ObjMap").ObjMap<unknown>, import("graphql/jsutils/ObjMap").ObjMap<unknown>> | {
36
28
  id: string;
37
29
  }>;
38
30
  private execute;