@makerx/graphql-core 2.0.0 → 2.1.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/README.md CHANGED
@@ -119,26 +119,11 @@ const graphqlServer = createServer({
119
119
 
120
120
  ### logGraphQLOperation
121
121
 
122
- The `logGraphQLOperation` function will log:
122
+ Logs a GraphQL operation in a consistent format with the option of including any additional data. Top level and result level log data with null or undefined values will be omitted for berevity.
123
123
 
124
- - `operationName`: the operation name, if supplied
125
- - `query`: the formatted graphql query or mutation, or 'IntrospectionQuery'
126
- - `variables`: the graphql request variables
127
- - `duration`: the duration of request processing
128
- - `errors`: the graphql response errors, if any
124
+ Refer to the `GraphQLLogOperationInfo` type for the definition of input.
129
125
 
130
- Notes:
131
-
132
- - null or undefined values will be omitted
133
- - introspection queries will not be logged outside of production
134
-
135
- This function can be used across implementations, e.g. in a [GraphQL Envelop plugin](https://www.envelop.dev/docs/plugins) or [ApolloServer plugin](https://www.apollographql.com/docs/apollo-server/integrations/plugins/).
136
-
137
- ### logGraphQLExecutionArgs
138
-
139
- The `logGraphQLExecutionArgs` will log `operationName`, `query` and `variables` params from the GraphQL `ExecutionArgs`.
140
-
141
- This can be used when logging from execution callbacks, e.g. graphql-ws Server [onOperation](https://the-guild.dev/graphql/ws/docs/interfaces/server.ServerOptions#onoperation) and [onNext](https://the-guild.dev/graphql/ws/docs/interfaces/server.ServerOptions#onnext).
126
+ This function can be used across implementations, e.g. in a [GraphQL Envelop plugin](https://www.envelop.dev/docs/plugins) or [ApolloServer plugin](https://github.com/MakerXStudio/graphql-apollo-server/blob/main/src/plugins/graphql-operation-logging-plugin.ts).
142
127
 
143
128
  ## GraphQL subscriptions
144
129
 
package/logging.d.ts CHANGED
@@ -1,21 +1,79 @@
1
1
  import { Logger } from '@makerx/node-common';
2
- import { ExecutionArgs, GraphQLFormattedError } from 'graphql';
3
- interface GraphQLLogOperationInfo {
4
- started: number;
2
+ import { ExecutionArgs, GraphQLFormattedError, OperationTypeNode } from 'graphql';
3
+ import { ExecutionResult } from 'graphql-ws';
4
+ type LogFunction = Logger['info'];
5
+ export type LoggerLogFunctions<T extends Logger> = {
6
+ [Property in keyof T]: LogFunction;
7
+ };
8
+ /**
9
+ * Info for logging a GraphQL operation in a consistent format with the option of including any additional data.
10
+ */
11
+ export interface GraphQLLogOperationInfo<TLogger extends Logger = Logger> extends Record<string, unknown> {
12
+ /**
13
+ * The message to log, defaults to 'GraphQL operation'.
14
+ */
15
+ message?: string;
16
+ /**
17
+ * The timestamp when the operation started, if supplied, the duration will be logged.
18
+ */
19
+ started?: number;
20
+ /**
21
+ * The type of GraphQL operation.
22
+ */
23
+ type?: OperationTypeNode | null;
24
+ /**
25
+ * The name of the GraphQL operation.
26
+ */
5
27
  operationName?: string | null;
28
+ /**
29
+ * The formatted GraphQL query.
30
+ */
6
31
  query?: string | null;
32
+ /**
33
+ * The GraphQL variables.
34
+ */
7
35
  variables?: Record<string, unknown> | null;
8
- result: {
36
+ /**
37
+ * The result of the GraphQL operation.
38
+ * Generally, we don't log the data or extensions, just errors.
39
+ */
40
+ result?: {
9
41
  data?: Record<string, unknown> | null;
10
42
  errors?: readonly GraphQLFormattedError[] | null;
43
+ extensions?: Record<string, unknown> | null;
44
+ hasNext?: boolean;
11
45
  };
12
- logger: Logger;
46
+ /**
47
+ * Whether the operation is an introspection query.
48
+ */
49
+ isIntrospectionQuery?: boolean;
50
+ /**
51
+ * Whether the operation is part of an incremental response.
52
+ */
53
+ isIncrementalResponse?: boolean;
54
+ /**
55
+ * Whether the operation is a subsequent payload of an incremental response.
56
+ */
57
+ isSubsequentPayload?: boolean;
58
+ /**
59
+ * The logger to use.
60
+ */
61
+ logger: TLogger;
62
+ /**
63
+ * The logger function to use, defaults to 'info'.
64
+ */
65
+ logLevel?: keyof LoggerLogFunctions<TLogger>;
13
66
  }
14
- export declare const logGraphQLOperation: ({ started, operationName, query, variables, result: { errors }, logger }: GraphQLLogOperationInfo) => void;
15
67
  /**
16
- * Logs `operationName`, `query` and `variables` params from the GraphQL `ExecutionArgs`.
17
- * If `args.contextValue` has a `logger` property, it will be used, otherwise the `logger` param will be used.
68
+ * Logs a GraphQL operation in a consistent format with the option of including any additional data.
69
+ * Top level and result entries with null or undefined values will be omitted.
18
70
  */
19
- export declare const logGraphQLExecutionArgs: (args: ExecutionArgs, message: string, logger?: Logger) => void;
71
+ export declare const logGraphQLOperation: <TLogger extends Logger = Logger>({ message, started, type, operationName, query, variables, result, logger, logLevel, ...rest }: GraphQLLogOperationInfo<TLogger>) => void;
72
+ export declare const logSubscriptionOperation: <TLogger extends Logger = Logger>({ args, result, message, logLevel, }: {
73
+ args: ExecutionArgs;
74
+ result?: ExecutionResult<Record<string, unknown>, Record<string, unknown>> | undefined;
75
+ message?: string | undefined;
76
+ logLevel?: keyof TLogger | undefined;
77
+ }) => void;
20
78
  export {};
21
79
  //# sourceMappingURL=logging.d.ts.map
package/logging.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAS,MAAM,SAAS,CAAA;AAKrE,UAAU,uBAAuB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC1C,MAAM,EAAE;QACN,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;QACrC,MAAM,CAAC,EAAE,SAAS,qBAAqB,EAAE,GAAG,IAAI,CAAA;KACjD,CAAA;IACD,MAAM,EAAE,MAAM,CAAA;CACf;AAED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UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;QAC3C,OAAO,CAAC,EAAE,OAAO,CAAA;KAClB,CAAA;IACD;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;OAEG;IACH,MAAM,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAA;CAC7C;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,6KA8B/B,CAAA;AAED,eAAO,MAAM,wBAAwB;UAM7B,aAAa;;;;UAqBpB,CAAA"}
package/logging.js CHANGED
@@ -3,36 +3,47 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.logGraphQLExecutionArgs = exports.logGraphQLOperation = void 0;
6
+ exports.logSubscriptionOperation = exports.logGraphQLOperation = void 0;
7
7
  const node_common_1 = require("@makerx/node-common");
8
8
  const graphql_1 = require("graphql");
9
9
  const lodash_omitby_1 = __importDefault(require("lodash.omitby"));
10
10
  const utils_1 = require("./utils");
11
- const logGraphQLOperation = ({ started, operationName, query, variables, result: { errors }, logger }) => {
11
+ /**
12
+ * Logs a GraphQL operation in a consistent format with the option of including any additional data.
13
+ * Top level and result entries with null or undefined values will be omitted.
14
+ */
15
+ const logGraphQLOperation = ({ message = 'GraphQL operation', started, type, operationName, query, variables, result, logger, logLevel = 'info', ...rest }) => {
12
16
  const isIntrospection = query && (0, utils_1.isIntrospectionQuery)(query);
13
17
  if (node_common_1.isLocalDev && isIntrospection)
14
18
  return;
15
- logger.info('GraphQL operation', (0, lodash_omitby_1.default)({
19
+ logger[logLevel](message, (0, lodash_omitby_1.default)({
20
+ type,
16
21
  operationName,
17
- query: isIntrospection ? 'IntrospectionQuery' : query,
22
+ query,
18
23
  variables: variables && Object.keys(variables).length > 0 ? variables : undefined,
19
- duration: Date.now() - started,
20
- errors,
24
+ duration: started ? Date.now() - started : undefined,
25
+ result: result ? (0, lodash_omitby_1.default)(result, utils_1.isNil) : undefined,
26
+ isIntrospectionQuery: isIntrospection || undefined,
27
+ ...(0, lodash_omitby_1.default)(rest, utils_1.isNil),
21
28
  }, utils_1.isNil));
22
29
  };
23
30
  exports.logGraphQLOperation = logGraphQLOperation;
24
- /**
25
- * Logs `operationName`, `query` and `variables` params from the GraphQL `ExecutionArgs`.
26
- * If `args.contextValue` has a `logger` property, it will be used, otherwise the `logger` param will be used.
27
- */
28
- const logGraphQLExecutionArgs = (args, message, logger) => {
31
+ const logSubscriptionOperation = ({ args, result, message, logLevel, }) => {
32
+ const logger = args.contextValue.logger;
33
+ if (!logger)
34
+ return;
29
35
  const { operationName, variableValues, document } = args;
30
- const contextLogger = args.contextValue.logger ?? logger;
31
- contextLogger?.info(message, (0, lodash_omitby_1.default)({
36
+ const { data, ...resultWithoutData } = result ?? {};
37
+ (0, exports.logGraphQLOperation)({
38
+ message,
39
+ type: graphql_1.OperationTypeNode.SUBSCRIPTION,
32
40
  operationName,
33
41
  query: (0, graphql_1.print)(document),
34
42
  variables: variableValues,
35
- }, utils_1.isNil));
43
+ result: resultWithoutData,
44
+ logger,
45
+ logLevel,
46
+ });
36
47
  };
37
- exports.logGraphQLExecutionArgs = logGraphQLExecutionArgs;
48
+ exports.logSubscriptionOperation = logSubscriptionOperation;
38
49
  //# sourceMappingURL=logging.js.map
package/logging.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAwD;AACxD,qCAAqE;AACrE,kEAAkC;AAClC,mCAAqD;AAe9C,MAAM,mBAAmB,GAAG,CAAC,EAAE,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GAAG,IAAI,CAAA;IACxD,MAAM,EAAE,IAAI,EAAE,GAAG,iBAAiB,EAAE,GAAG,MAAM,IAAI,EAAE,CAAA;IAEnD,IAAA,2BAAmB,EAAC;QAClB,OAAO;QACP,IAAI,EAAE,2BAAiB,CAAC,YAAY;QACpC,aAAa;QACb,KAAK,EAAE,IAAA,eAAK,EAAC,QAAQ,CAAC;QACtB,SAAS,EAAE,cAAc;QACzB,MAAM,EAAE,iBAAiB;QACzB,MAAM;QACN,QAAQ;KACT,CAAC,CAAA;AACJ,CAAC,CAAA;AA3BY,QAAA,wBAAwB,4BA2BpC"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "main": "index.js",
3
3
  "types": "index.d.ts",
4
4
  "name": "@makerx/graphql-core",
5
- "version": "2.0.0",
5
+ "version": "2.1.0",
6
6
  "private": false,
7
7
  "description": "A set of core GraphQL utilities that MakerX uses to build GraphQL APIs",
8
8
  "author": "MakerX",
@@ -4,11 +4,12 @@ import { GraphQLSchema } from 'graphql';
4
4
  import type { Server } from 'http';
5
5
  import { JwtPayload } from '../context';
6
6
  import { CreateSubscriptionContext } from './context';
7
- export declare function useSubscriptionsServer({ schema, httpServer, createSubscriptionContext, logger, path, verifyToken, requireAuth, jwtClaimsToLog, }: {
7
+ export declare function useSubscriptionsServer<TLogger extends Logger = Logger>({ schema, httpServer, createSubscriptionContext, logger, operationLogLevel, path, verifyToken, requireAuth, jwtClaimsToLog, }: {
8
8
  schema: GraphQLSchema;
9
9
  httpServer: Server;
10
10
  createSubscriptionContext: CreateSubscriptionContext;
11
- logger: Logger;
11
+ logger: TLogger;
12
+ operationLogLevel?: keyof TLogger;
12
13
  path?: string;
13
14
  verifyToken?: (host: string, token: string) => Promise<JwtPayload>;
14
15
  requireAuth?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/subscriptions/server.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB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ACD,MAAM,EAAE,aAAa,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,yBAAyB,EAAE,yBAAyB,CAAA;IACpD,MAAM,EAAE,OAAO,CAAA;IACf,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAA;IACjC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;IAClE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;CAC1B,mCA+EA"}
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.useSubscriptionsServer = void 0;
7
+ const graphql_ws_1 = require("graphql-ws");
7
8
  const ws_1 = require("graphql-ws/lib/use/ws");
8
9
  const lodash_pick_1 = __importDefault(require("lodash.pick"));
9
10
  const ws_2 = require("ws");
10
11
  const logging_1 = require("../logging");
11
12
  const utils_1 = require("./utils");
12
- const graphql_ws_1 = require("graphql-ws");
13
- function useSubscriptionsServer({ schema, httpServer, createSubscriptionContext, logger, path = '/graphql', verifyToken, requireAuth, jwtClaimsToLog = ['oid', 'iss'], }) {
13
+ function useSubscriptionsServer({ schema, httpServer, createSubscriptionContext, logger, operationLogLevel = 'info', path = '/graphql', verifyToken, requireAuth, jwtClaimsToLog = ['oid', 'iss'], }) {
14
14
  if (requireAuth && !verifyToken)
15
15
  throw new Error('verifyToken must be supplied when requireAuth is true');
16
16
  const wsServer = new ws_2.WebSocketServer({
@@ -80,10 +80,10 @@ function useSubscriptionsServer({ schema, httpServer, createSubscriptionContext,
80
80
  });
81
81
  },
82
82
  onOperation(_ctx, _message, args) {
83
- (0, logging_1.logGraphQLExecutionArgs)(args, 'GraphQL subscription operation');
83
+ (0, logging_1.logSubscriptionOperation)({ args, logLevel: operationLogLevel });
84
84
  },
85
- onNext(_ctx, _message, args, _result) {
86
- (0, logging_1.logGraphQLExecutionArgs)(args, 'GraphQL subscription result');
85
+ onNext(_ctx, _message, args, { data, ...result }) {
86
+ (0, logging_1.logSubscriptionOperation)({ args, logLevel: operationLogLevel, result });
87
87
  },
88
88
  }, wsServer);
89
89
  }
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/subscriptions/server.ts"],"names":[],"mappings":";;;;;;AAEA,8CAAiD;AAEjD,8DAA8B;AAC9B,2BAAoC;AAEpC,wCAAoD;AAEpD,mCAAmE;AACnE,2CAAsC;AAEtC,SAAgB,sBAAsB,CAAC,EACrC,MAAM,EACN,UAAU,EACV,yBAAyB,EACzB,MAAM,EACN,IAAI,GAAG,UAAU,EACjB,WAAW,EACX,WAAW,EACX,cAAc,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,GAUhC;IACC,IAAI,WAAW,IAAI,CAAC,WAAW;QAAE,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAA;IAEzG,MAAM,QAAQ,GAAG,IAAI,oBAAe,CAAC;QACnC,MAAM,EAAE,UAAU;QAClB,IAAI;KACL,CAAC,CAAA;IAEF,OAAO,IAAA,cAAS,EACd;QACE,MAAM;QACN,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM;YAC3B,MAAM,CAAC,KAAK,CAAC,oCAAoC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;QACzE,CAAC;QACD,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;YACvB,MAAM,qBAAqB,GAAG,qCAAqC,CAAA;YACnE,IAAI,CAAC,WAAW,EAAE;gBAChB,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;gBAClC,OAAO,IAAI,CAAA;aACZ;YAED,MAAM,KAAK,GAAG,IAAA,wCAAgC,EAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;YACpE,IAAI,CAAC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