@envelop/preload-assets 1.2.0 → 1.2.2-alpha-63e92f8.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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Plugin } from '@envelop/types';
1
+ import { Plugin } from '@envelop/core';
2
2
  export declare type UsePreloadAssetsOpts = {
3
3
  shouldPreloadAssets?: (context: unknown) => boolean;
4
4
  };
package/index.js CHANGED
@@ -2,37 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- /**
6
- * Returns true if the provided object implements the AsyncIterator protocol via
7
- * implementing a `Symbol.asyncIterator` method.
8
- *
9
- * Source: https://github.com/graphql/graphql-js/blob/main/src/jsutils/isAsyncIterable.ts
10
- */
11
- function isAsyncIterable(maybeAsyncIterable) {
12
- return (maybeAsyncIterable != null &&
13
- typeof maybeAsyncIterable === 'object' &&
14
- typeof maybeAsyncIterable[Symbol.asyncIterator] === 'function');
15
- }
16
- /**
17
- * A utility function for hanlding `onExecuteDone` hook result, for simplifying the hanlding of AsyncIterable returned from `execute`.
18
- *
19
- * @param payload The payload send to `onExecuteDone` hook function
20
- * @param fn The handler to be executed on each result
21
- * @returns a subscription for streamed results, or undefined in case of an non-async
22
- */
23
- function handleStreamOrSingleExecutionResult(payload, fn) {
24
- if (isAsyncIterable(payload.result)) {
25
- return { onNext: fn };
26
- }
27
- else {
28
- fn({
29
- args: payload.args,
30
- result: payload.result,
31
- setResult: payload.setResult,
32
- });
33
- return undefined;
34
- }
35
- }
5
+ const core = require('@envelop/core');
36
6
 
37
7
  const usePreloadAssets = (opts) => ({
38
8
  onExecute: ({ extendContext, args }) => {
@@ -47,7 +17,7 @@ const usePreloadAssets = (opts) => ({
47
17
  if (!assets.size) {
48
18
  return;
49
19
  }
50
- return handleStreamOrSingleExecutionResult(payload, ({ result, setResult }) => {
20
+ return core.handleStreamOrSingleExecutionResult(payload, ({ result, setResult }) => {
51
21
  setResult({
52
22
  ...result,
53
23
  extensions: {
package/index.mjs CHANGED
@@ -1,34 +1,4 @@
1
- /**
2
- * Returns true if the provided object implements the AsyncIterator protocol via
3
- * implementing a `Symbol.asyncIterator` method.
4
- *
5
- * Source: https://github.com/graphql/graphql-js/blob/main/src/jsutils/isAsyncIterable.ts
6
- */
7
- function isAsyncIterable(maybeAsyncIterable) {
8
- return (maybeAsyncIterable != null &&
9
- typeof maybeAsyncIterable === 'object' &&
10
- typeof maybeAsyncIterable[Symbol.asyncIterator] === 'function');
11
- }
12
- /**
13
- * A utility function for hanlding `onExecuteDone` hook result, for simplifying the hanlding of AsyncIterable returned from `execute`.
14
- *
15
- * @param payload The payload send to `onExecuteDone` hook function
16
- * @param fn The handler to be executed on each result
17
- * @returns a subscription for streamed results, or undefined in case of an non-async
18
- */
19
- function handleStreamOrSingleExecutionResult(payload, fn) {
20
- if (isAsyncIterable(payload.result)) {
21
- return { onNext: fn };
22
- }
23
- else {
24
- fn({
25
- args: payload.args,
26
- result: payload.result,
27
- setResult: payload.setResult,
28
- });
29
- return undefined;
30
- }
31
- }
1
+ import { handleStreamOrSingleExecutionResult } from '@envelop/core';
32
2
 
33
3
  const usePreloadAssets = (opts) => ({
34
4
  onExecute: ({ extendContext, args }) => {
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@envelop/preload-assets",
3
- "version": "1.2.0",
3
+ "version": "1.2.2-alpha-63e92f8.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
+ "@envelop/core": "1.6.6-alpha-63e92f8.0",
6
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
7
8
  },
8
9
  "repository": {
@@ -26,6 +27,7 @@
26
27
  "./*": {
27
28
  "require": "./*.js",
28
29
  "import": "./*.mjs"
29
- }
30
+ },
31
+ "./package.json": "./package.json"
30
32
  }
31
33
  }