@graphql-tools/apollo-engine-loader 7.3.1 → 7.3.2-alpha-b93d3b57.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/cjs/index.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SCHEMA_QUERY = exports.ApolloEngineLoader = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const utils_1 = require("@graphql-tools/utils");
6
- const cross_undici_fetch_1 = require("cross-undici-fetch");
6
+ const fetch_1 = require("@whatwg-node/fetch");
7
7
  const sync_fetch_1 = tslib_1.__importDefault(require("sync-fetch"));
8
8
  const DEFAULT_APOLLO_ENDPOINT = 'https://engine-graphql.apollographql.com/api/graphql';
9
9
  /**
@@ -45,7 +45,7 @@ class ApolloEngineLoader {
45
45
  return [];
46
46
  }
47
47
  const fetchArgs = this.getFetchArgs(options);
48
- const response = await (0, cross_undici_fetch_1.fetch)(...fetchArgs);
48
+ const response = await (0, fetch_1.fetch)(...fetchArgs);
49
49
  const { data, errors } = await response.json();
50
50
  if (errors) {
51
51
  throw new utils_1.AggregateError(errors, 'Introspection from Apollo Engine failed; \n ' + errors.map((e) => e.message).join('\n'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/apollo-engine-loader",
3
- "version": "7.3.1",
3
+ "version": "7.3.2-alpha-b93d3b57.0",
4
4
  "description": "A set of utils for faster development of GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@graphql-tools/utils": "8.8.0",
11
- "cross-undici-fetch": "^0.4.11",
11
+ "@whatwg-node/fetch": "^0.0.2",
12
12
  "sync-fetch": "0.4.1",
13
13
  "tslib": "^2.4.0"
14
14
  },
package/esm/index.js DELETED
@@ -1,80 +0,0 @@
1
- import { parseGraphQLSDL, AggregateError } from '@graphql-tools/utils';
2
- import { fetch } from 'cross-undici-fetch';
3
- import syncFetch from 'sync-fetch';
4
- const DEFAULT_APOLLO_ENDPOINT = 'https://engine-graphql.apollographql.com/api/graphql';
5
- /**
6
- * This loader loads a schema from Apollo Engine
7
- */
8
- export class ApolloEngineLoader {
9
- getFetchArgs(options) {
10
- return [
11
- options.engine.endpoint || DEFAULT_APOLLO_ENDPOINT,
12
- {
13
- method: 'POST',
14
- headers: {
15
- 'x-api-key': options.engine.apiKey,
16
- 'apollo-client-name': 'Apollo Language Server',
17
- 'apollo-client-reference-id': '146d29c0-912c-46d3-b686-920e52586be6',
18
- 'apollo-client-version': '2.6.8',
19
- 'Content-Type': 'application/json',
20
- Accept: 'application/json',
21
- ...options.headers,
22
- },
23
- body: JSON.stringify({
24
- query: SCHEMA_QUERY,
25
- variables: {
26
- id: options.graph,
27
- tag: options.variant,
28
- },
29
- }),
30
- },
31
- ];
32
- }
33
- async canLoad(ptr) {
34
- return this.canLoadSync(ptr);
35
- }
36
- canLoadSync(ptr) {
37
- return typeof ptr === 'string' && ptr === 'apollo-engine';
38
- }
39
- async load(pointer, options) {
40
- if (!(await this.canLoad(pointer))) {
41
- return [];
42
- }
43
- const fetchArgs = this.getFetchArgs(options);
44
- const response = await fetch(...fetchArgs);
45
- const { data, errors } = await response.json();
46
- if (errors) {
47
- throw new AggregateError(errors, 'Introspection from Apollo Engine failed; \n ' + errors.map((e) => e.message).join('\n'));
48
- }
49
- const source = parseGraphQLSDL(pointer, data.service.schema.document, options);
50
- return [source];
51
- }
52
- loadSync(pointer, options) {
53
- if (!this.canLoadSync(pointer)) {
54
- return [];
55
- }
56
- const fetchArgs = this.getFetchArgs(options);
57
- const response = syncFetch(...fetchArgs);
58
- const { data, errors } = response.json();
59
- if (errors) {
60
- throw new AggregateError(errors, 'Introspection from Apollo Engine failed; \n ' + errors.map((e) => e.message).join('\n'));
61
- }
62
- const source = parseGraphQLSDL(pointer, data.service.schema.document, options);
63
- return [source];
64
- }
65
- }
66
- /**
67
- * @internal
68
- */
69
- export const SCHEMA_QUERY = /* GraphQL */ `
70
- query GetSchemaByTag($tag: String!, $id: ID!) {
71
- service(id: $id) {
72
- ... on Service {
73
- __typename
74
- schema(tag: $tag) {
75
- document
76
- }
77
- }
78
- }
79
- }
80
- `;
@@ -1,27 +0,0 @@
1
- import { Source, BaseLoaderOptions, Loader } from '@graphql-tools/utils';
2
- /**
3
- * Additional options for loading from Apollo Engine
4
- */
5
- export interface ApolloEngineOptions extends BaseLoaderOptions {
6
- engine: {
7
- endpoint?: string;
8
- apiKey: string;
9
- };
10
- graph: string;
11
- variant: string;
12
- headers?: Record<string, string>;
13
- }
14
- /**
15
- * This loader loads a schema from Apollo Engine
16
- */
17
- export declare class ApolloEngineLoader implements Loader<ApolloEngineOptions> {
18
- private getFetchArgs;
19
- canLoad(ptr: string): Promise<boolean>;
20
- canLoadSync(ptr: string): boolean;
21
- load(pointer: string, options: ApolloEngineOptions): Promise<Source[]>;
22
- loadSync(pointer: string, options: ApolloEngineOptions): Source[];
23
- }
24
- /**
25
- * @internal
26
- */
27
- export declare const SCHEMA_QUERY = "\n query GetSchemaByTag($tag: String!, $id: ID!) {\n service(id: $id) {\n ... on Service {\n __typename\n schema(tag: $tag) {\n document\n }\n }\n }\n }\n";