@envelop/graphql-jit 11.1.1 → 11.2.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 CHANGED
@@ -1,6 +1,8 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Dotan Simha
3
+ Copyright (c) 2018-2020 Graphcool
4
+ Copyright (c) 2020-2021 Prisma
5
+ Copyright (c) 2021- The Guild
4
6
 
5
7
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
8
  of this software and associated documentation files (the "Software"), to deal
package/cjs/index.js CHANGED
@@ -18,7 +18,10 @@ const useGraphQlJit = (compilerOptions = {}, pluginOptions = {}) => {
18
18
  }
19
19
  if (!cacheEntry) {
20
20
  const compilationResult = (0, graphql_jit_1.compileQuery)(args.schema, args.document, args.operationName ?? undefined, compilerOptions);
21
- if (!(0, graphql_jit_1.isCompiledQuery)(compilationResult)) {
21
+ if ((0, graphql_jit_1.isCompiledQuery)(compilationResult)) {
22
+ cacheEntry = compilationResult;
23
+ }
24
+ else {
22
25
  if (pluginOptions?.onError) {
23
26
  pluginOptions.onError(compilationResult);
24
27
  }
@@ -30,9 +33,6 @@ const useGraphQlJit = (compilerOptions = {}, pluginOptions = {}) => {
30
33
  stringify: r => JSON.stringify(r),
31
34
  };
32
35
  }
33
- else {
34
- cacheEntry = compilationResult;
35
- }
36
36
  jitCacheByDocument.set(args.document, cacheEntry);
37
37
  if (jitCacheByDocumentString) {
38
38
  const documentSource = (0, core_1.getDocumentString)(args.document);
@@ -45,7 +45,7 @@ const useGraphQlJit = (compilerOptions = {}, pluginOptions = {}) => {
45
45
  }
46
46
  function jitExecutor(args) {
47
47
  const cacheEntry = getCacheEntry(args);
48
- const executeFn = cacheEntry.subscribe ? cacheEntry.subscribe : cacheEntry.query;
48
+ const executeFn = cacheEntry.subscribe ?? cacheEntry.query;
49
49
  return (0, promise_helpers_1.handleMaybePromise)(() => executeFn(args.rootValue, args.contextValue, args.variableValues), result => {
50
50
  result.stringify = cacheEntry.stringify;
51
51
  return result;
package/esm/index.js CHANGED
@@ -15,7 +15,10 @@ export const useGraphQlJit = (compilerOptions = {}, pluginOptions = {}) => {
15
15
  }
16
16
  if (!cacheEntry) {
17
17
  const compilationResult = compileQuery(args.schema, args.document, args.operationName ?? undefined, compilerOptions);
18
- if (!isCompiledQuery(compilationResult)) {
18
+ if (isCompiledQuery(compilationResult)) {
19
+ cacheEntry = compilationResult;
20
+ }
21
+ else {
19
22
  if (pluginOptions?.onError) {
20
23
  pluginOptions.onError(compilationResult);
21
24
  }
@@ -27,9 +30,6 @@ export const useGraphQlJit = (compilerOptions = {}, pluginOptions = {}) => {
27
30
  stringify: r => JSON.stringify(r),
28
31
  };
29
32
  }
30
- else {
31
- cacheEntry = compilationResult;
32
- }
33
33
  jitCacheByDocument.set(args.document, cacheEntry);
34
34
  if (jitCacheByDocumentString) {
35
35
  const documentSource = getDocumentString(args.document);
@@ -42,7 +42,7 @@ export const useGraphQlJit = (compilerOptions = {}, pluginOptions = {}) => {
42
42
  }
43
43
  function jitExecutor(args) {
44
44
  const cacheEntry = getCacheEntry(args);
45
- const executeFn = cacheEntry.subscribe ? cacheEntry.subscribe : cacheEntry.query;
45
+ const executeFn = cacheEntry.subscribe ?? cacheEntry.query;
46
46
  return handleMaybePromise(() => executeFn(args.rootValue, args.contextValue, args.variableValues), result => {
47
47
  result.stringify = cacheEntry.stringify;
48
48
  return result;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@envelop/graphql-jit",
3
- "version": "11.1.1",
3
+ "version": "11.2.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0",
7
- "@envelop/core": "^5.5.1"
6
+ "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
7
+ "@envelop/core": "^5.6.0"
8
8
  },
9
9
  "dependencies": {
10
10
  "@whatwg-node/promise-helpers": "^1.2.3",
@@ -13,8 +13,8 @@
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "https://github.com/graphql-hive/envelop.git",
17
- "directory": "packages/plugins/graphql-jit"
16
+ "url": "https://github.com/graphql-hive/graphql-yoga.git",
17
+ "directory": "packages/envelop/plugins/graphql-jit"
18
18
  },
19
19
  "author": "Dotan Simha <dotansimha@gmail.com>",
20
20
  "license": "MIT",
@@ -1,6 +1,6 @@
1
- import { ExecutionArgs, ExecutionResult } from 'graphql';
2
- import { CompiledQuery, CompilerOptions } from 'graphql-jit';
3
- import { Plugin } from '@envelop/core';
1
+ import type { ExecutionArgs, ExecutionResult } from 'graphql';
2
+ import type { CompiledQuery, CompilerOptions } from 'graphql-jit';
3
+ import type { Plugin } from '@envelop/core';
4
4
  type JSONStringifier = (result: any) => string;
5
5
  type JITCacheEntry = {
6
6
  query: CompiledQuery['query'];
@@ -1,6 +1,6 @@
1
- import { ExecutionArgs, ExecutionResult } from 'graphql';
2
- import { CompiledQuery, CompilerOptions } from 'graphql-jit';
3
- import { Plugin } from '@envelop/core';
1
+ import type { ExecutionArgs, ExecutionResult } from 'graphql';
2
+ import type { CompiledQuery, CompilerOptions } from 'graphql-jit';
3
+ import type { Plugin } from '@envelop/core';
4
4
  type JSONStringifier = (result: any) => string;
5
5
  type JITCacheEntry = {
6
6
  query: CompiledQuery['query'];