@envelop/persisted-operations 10.1.1 → 10.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
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JsonFileStore = void 0;
4
- const fs_1 = require("fs");
4
+ const node_fs_1 = require("node:fs");
5
5
  class JsonFileStore {
6
6
  storeData = null;
7
7
  get(operationId) {
@@ -11,11 +11,11 @@ class JsonFileStore {
11
11
  return this.storeData.get(operationId) || undefined;
12
12
  }
13
13
  loadFromFileSync(path) {
14
- const data = JSON.parse((0, fs_1.readFileSync)(path, 'utf-8'));
14
+ const data = JSON.parse((0, node_fs_1.readFileSync)(path, 'utf-8'));
15
15
  this.storeData = new Map(Object.entries(data));
16
16
  }
17
17
  loadFromFile(path) {
18
- return fs_1.promises.readFile(path, 'utf-8').then(data => {
18
+ return node_fs_1.promises.readFile(path, 'utf-8').then(data => {
19
19
  this.storeData = new Map(Object.entries(JSON.parse(data)));
20
20
  });
21
21
  }
package/cjs/utils.js CHANGED
@@ -2,7 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.operationIdFromSource = operationIdFromSource;
4
4
  function operationIdFromSource(source) {
5
- return typeof source === 'string' && source.length && source.indexOf('{') === -1
6
- ? source
7
- : undefined;
5
+ return typeof source === 'string' && source.length && !source.includes('{') ? source : undefined;
8
6
  }
@@ -1,4 +1,4 @@
1
- import { promises, readFileSync } from 'fs';
1
+ import { promises, readFileSync } from 'node:fs';
2
2
  export class JsonFileStore {
3
3
  storeData = null;
4
4
  get(operationId) {
package/esm/utils.js CHANGED
@@ -1,5 +1,3 @@
1
1
  export function operationIdFromSource(source) {
2
- return typeof source === 'string' && source.length && source.indexOf('{') === -1
3
- ? source
4
- : undefined;
2
+ return typeof source === 'string' && source.length && !source.includes('{') ? source : undefined;
5
3
  }
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@envelop/persisted-operations",
3
- "version": "10.1.1",
3
+ "version": "10.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
  "tslib": "^2.5.0"
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "https://github.com/graphql-hive/envelop.git",
15
- "directory": "packages/plugins/persisted-operations"
14
+ "url": "https://github.com/graphql-hive/graphql-yoga.git",
15
+ "directory": "packages/envelop/plugins/persisted-operations"
16
16
  },
17
17
  "author": "Dotan Simha <dotansimha@gmail.com>",
18
18
  "license": "MIT",
@@ -1,5 +1,5 @@
1
- import { DefaultContext, Plugin } from '@envelop/core';
2
- import { PersistedOperationsFunctionStore, PersistedOperationsStore } from './types.cjs';
1
+ import type { DefaultContext, Plugin } from '@envelop/core';
2
+ import type { PersistedOperationsFunctionStore, PersistedOperationsStore } from './types.cjs';
3
3
  export type UsePersistedOperationsOptions<ContextType = DefaultContext> = {
4
4
  /**
5
5
  * Set to `false` to allow running operations that are not available in the store.
@@ -1,5 +1,5 @@
1
- import { DefaultContext, Plugin } from '@envelop/core';
2
- import { PersistedOperationsFunctionStore, PersistedOperationsStore } from './types.js';
1
+ import type { DefaultContext, Plugin } from '@envelop/core';
2
+ import type { PersistedOperationsFunctionStore, PersistedOperationsStore } from './types.js';
3
3
  export type UsePersistedOperationsOptions<ContextType = DefaultContext> = {
4
4
  /**
5
5
  * Set to `false` to allow running operations that are not available in the store.
@@ -1,5 +1,5 @@
1
- import { DocumentNode } from 'graphql';
2
- import { PersistedOperationsStore } from '../types.cjs';
1
+ import type { DocumentNode } from 'graphql';
2
+ import type { PersistedOperationsStore } from '../types.cjs';
3
3
  export declare class AggregatedStore implements PersistedOperationsStore {
4
4
  private stores;
5
5
  constructor(stores: PersistedOperationsStore[]);
@@ -1,5 +1,5 @@
1
- import { DocumentNode } from 'graphql';
2
- import { PersistedOperationsStore } from '../types.js';
1
+ import type { DocumentNode } from 'graphql';
2
+ import type { PersistedOperationsStore } from '../types.js';
3
3
  export declare class AggregatedStore implements PersistedOperationsStore {
4
4
  private stores;
5
5
  constructor(stores: PersistedOperationsStore[]);
@@ -1,5 +1,5 @@
1
- import { DocumentNode } from 'graphql';
2
- import { PersistedOperationsStore } from '../types.cjs';
1
+ import type { DocumentNode } from 'graphql';
2
+ import type { PersistedOperationsStore } from '../types.cjs';
3
3
  export type InMemoryStoreDataMap = Map<string, DocumentNode | string>;
4
4
  export declare class InMemoryStore implements PersistedOperationsStore {
5
5
  private storeData;
@@ -1,5 +1,5 @@
1
- import { DocumentNode } from 'graphql';
2
- import { PersistedOperationsStore } from '../types.js';
1
+ import type { DocumentNode } from 'graphql';
2
+ import type { PersistedOperationsStore } from '../types.js';
3
3
  export type InMemoryStoreDataMap = Map<string, DocumentNode | string>;
4
4
  export declare class InMemoryStore implements PersistedOperationsStore {
5
5
  private storeData;
@@ -1,5 +1,5 @@
1
- import { DocumentNode } from 'graphql';
2
- import { PersistedOperationsStore } from '../types.cjs';
1
+ import type { DocumentNode } from 'graphql';
2
+ import type { PersistedOperationsStore } from '../types.cjs';
3
3
  export type JsonFileStoreDataMap = Map<string, DocumentNode | string>;
4
4
  export declare class JsonFileStore implements PersistedOperationsStore {
5
5
  private storeData;
@@ -1,5 +1,5 @@
1
- import { DocumentNode } from 'graphql';
2
- import { PersistedOperationsStore } from '../types.js';
1
+ import type { DocumentNode } from 'graphql';
2
+ import type { PersistedOperationsStore } from '../types.js';
3
3
  export type JsonFileStoreDataMap = Map<string, DocumentNode | string>;
4
4
  export declare class JsonFileStore implements PersistedOperationsStore {
5
5
  private storeData;
@@ -1,5 +1,5 @@
1
- import { DocumentNode } from 'graphql';
2
- import { DefaultContext } from '@envelop/core';
1
+ import type { DocumentNode } from 'graphql';
2
+ import type { DefaultContext } from '@envelop/core';
3
3
  export interface PersistedOperationsStore {
4
4
  /**
5
5
  * Transfroms a hash/id into a DocumentNode or SDL string.
@@ -1,5 +1,5 @@
1
- import { DocumentNode } from 'graphql';
2
- import { DefaultContext } from '@envelop/core';
1
+ import type { DocumentNode } from 'graphql';
2
+ import type { DefaultContext } from '@envelop/core';
3
3
  export interface PersistedOperationsStore {
4
4
  /**
5
5
  * Transfroms a hash/id into a DocumentNode or SDL string.
@@ -1,2 +1,2 @@
1
- import { Source } from 'graphql';
1
+ import type { Source } from 'graphql';
2
2
  export declare function operationIdFromSource(source: string | Source): string | undefined;
@@ -1,2 +1,2 @@
1
- import { Source } from 'graphql';
1
+ import type { Source } from 'graphql';
2
2
  export declare function operationIdFromSource(source: string | Source): string | undefined;