@graphql-mesh/transport-rest 0.0.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.
Files changed (78) hide show
  1. package/cjs/directives/dictionary.js +19 -0
  2. package/cjs/directives/discriminator.js +9 -0
  3. package/cjs/directives/flatten.js +16 -0
  4. package/cjs/directives/getTypeResolverForAbstractType.js +102 -0
  5. package/cjs/directives/httpOperation.js +404 -0
  6. package/cjs/directives/isFileUpload.js +7 -0
  7. package/cjs/directives/jsonApiFields.js +23 -0
  8. package/cjs/directives/length.js +26 -0
  9. package/cjs/directives/link.js +67 -0
  10. package/cjs/directives/process.js +181 -0
  11. package/cjs/directives/pubsubOperation.js +31 -0
  12. package/cjs/directives/regexp.js +24 -0
  13. package/cjs/directives/resolveDataByUnionInputType.js +39 -0
  14. package/cjs/directives/resolveRoot.js +10 -0
  15. package/cjs/directives/resolveRootField.js +29 -0
  16. package/cjs/directives/responseMetadata.js +16 -0
  17. package/cjs/directives/scalars.js +53 -0
  18. package/cjs/directives/typescriptAnnotations.js +8 -0
  19. package/cjs/index.js +20 -0
  20. package/cjs/package.json +1 -0
  21. package/esm/directives/dictionary.js +15 -0
  22. package/esm/directives/discriminator.js +5 -0
  23. package/esm/directives/flatten.js +12 -0
  24. package/esm/directives/getTypeResolverForAbstractType.js +98 -0
  25. package/esm/directives/httpOperation.js +399 -0
  26. package/esm/directives/isFileUpload.js +3 -0
  27. package/esm/directives/jsonApiFields.js +18 -0
  28. package/esm/directives/length.js +22 -0
  29. package/esm/directives/link.js +63 -0
  30. package/esm/directives/process.js +177 -0
  31. package/esm/directives/pubsubOperation.js +27 -0
  32. package/esm/directives/regexp.js +20 -0
  33. package/esm/directives/resolveDataByUnionInputType.js +35 -0
  34. package/esm/directives/resolveRoot.js +6 -0
  35. package/esm/directives/resolveRootField.js +25 -0
  36. package/esm/directives/responseMetadata.js +12 -0
  37. package/esm/directives/scalars.js +48 -0
  38. package/esm/directives/typescriptAnnotations.js +4 -0
  39. package/esm/index.js +15 -0
  40. package/package.json +56 -0
  41. package/typings/directives/dictionary.d.cts +2 -0
  42. package/typings/directives/dictionary.d.ts +2 -0
  43. package/typings/directives/discriminator.d.cts +5 -0
  44. package/typings/directives/discriminator.d.ts +5 -0
  45. package/typings/directives/flatten.d.cts +2 -0
  46. package/typings/directives/flatten.d.ts +2 -0
  47. package/typings/directives/getTypeResolverForAbstractType.d.cts +7 -0
  48. package/typings/directives/getTypeResolverForAbstractType.d.ts +7 -0
  49. package/typings/directives/httpOperation.d.cts +28 -0
  50. package/typings/directives/httpOperation.d.ts +28 -0
  51. package/typings/directives/isFileUpload.d.cts +4 -0
  52. package/typings/directives/isFileUpload.d.ts +4 -0
  53. package/typings/directives/jsonApiFields.d.cts +2 -0
  54. package/typings/directives/jsonApiFields.d.ts +2 -0
  55. package/typings/directives/length.d.cts +5 -0
  56. package/typings/directives/length.d.ts +5 -0
  57. package/typings/directives/link.d.cts +2 -0
  58. package/typings/directives/link.d.ts +2 -0
  59. package/typings/directives/process.d.cts +12 -0
  60. package/typings/directives/process.d.ts +12 -0
  61. package/typings/directives/pubsubOperation.d.cts +10 -0
  62. package/typings/directives/pubsubOperation.d.ts +10 -0
  63. package/typings/directives/regexp.d.cts +2 -0
  64. package/typings/directives/regexp.d.ts +2 -0
  65. package/typings/directives/resolveDataByUnionInputType.d.cts +2 -0
  66. package/typings/directives/resolveDataByUnionInputType.d.ts +2 -0
  67. package/typings/directives/resolveRoot.d.cts +2 -0
  68. package/typings/directives/resolveRoot.d.ts +2 -0
  69. package/typings/directives/resolveRootField.d.cts +2 -0
  70. package/typings/directives/resolveRootField.d.ts +2 -0
  71. package/typings/directives/responseMetadata.d.cts +2 -0
  72. package/typings/directives/responseMetadata.d.ts +2 -0
  73. package/typings/directives/scalars.d.cts +3 -0
  74. package/typings/directives/scalars.d.ts +3 -0
  75. package/typings/directives/typescriptAnnotations.d.cts +2 -0
  76. package/typings/directives/typescriptAnnotations.d.ts +2 -0
  77. package/typings/index.d.cts +7 -0
  78. package/typings/index.d.ts +7 -0
@@ -0,0 +1,177 @@
1
+ import { isEnumType, isInterfaceType, isScalarType, isUnionType, } from 'graphql';
2
+ import { ObjMapScalar } from '@graphql-mesh/transport-common';
3
+ import { getDirective, getDirectives } from '@graphql-tools/utils';
4
+ import { processDictionaryDirective } from './dictionary';
5
+ import { processDiscriminatorAnnotations } from './discriminator';
6
+ import { processFlattenAnnotations } from './flatten';
7
+ import { getTypeResolverForAbstractType } from './getTypeResolverForAbstractType';
8
+ import { addHTTPRootFieldResolver } from './httpOperation';
9
+ import { processLinkFieldAnnotations } from './link';
10
+ import { processPubSubOperationAnnotations } from './pubsubOperation';
11
+ import { processResolveRootAnnotations } from './resolveRoot';
12
+ import { processResolveRootFieldAnnotations } from './resolveRootField';
13
+ import { processResponseMetadataAnnotations } from './responseMetadata';
14
+ import { addExecutionLogicToScalar, processScalarType } from './scalars';
15
+ import { processTypeScriptAnnotations } from './typescriptAnnotations';
16
+ export function processDirectives(schema, { globalFetch, logger, pubsub, ...extraGlobalOptions } = {}) {
17
+ const nonExecutableObjMapScalar = schema.getType('ObjMap');
18
+ if (nonExecutableObjMapScalar && isScalarType(nonExecutableObjMapScalar)) {
19
+ addExecutionLogicToScalar(nonExecutableObjMapScalar, ObjMapScalar);
20
+ }
21
+ const transportDirectives = getDirective(schema, schema, 'transport');
22
+ const currDirective = transportDirectives?.[0];
23
+ const globalOptions = {
24
+ endpoint: currDirective?.location,
25
+ operationHeaders: currDirective?.headers,
26
+ queryParams: currDirective?.queryParams,
27
+ queryStringOptions: currDirective?.queryStringOptions,
28
+ ...extraGlobalOptions,
29
+ };
30
+ if (typeof globalOptions.operationHeaders === 'string') {
31
+ globalOptions.operationHeaders = JSON.parse(globalOptions.operationHeaders);
32
+ }
33
+ if (typeof globalOptions.queryParams === 'string') {
34
+ globalOptions.queryParams = JSON.parse(globalOptions.queryParams);
35
+ }
36
+ const typeMap = schema.getTypeMap();
37
+ for (const typeName in typeMap) {
38
+ const type = typeMap[typeName];
39
+ const exampleAnnotations = getDirective(schema, type, 'example');
40
+ if (exampleAnnotations?.length) {
41
+ const examples = [];
42
+ for (const exampleAnnotation of exampleAnnotations) {
43
+ if (exampleAnnotation?.value) {
44
+ examples.push(exampleAnnotation.value);
45
+ }
46
+ }
47
+ type.extensions = type.extensions || {};
48
+ type.extensions.examples = examples;
49
+ }
50
+ if (isScalarType(type)) {
51
+ processScalarType(schema, type);
52
+ }
53
+ if (isInterfaceType(type)) {
54
+ const directiveAnnotations = getDirectives(schema, type);
55
+ for (const directiveAnnotation of directiveAnnotations) {
56
+ switch (directiveAnnotation.name) {
57
+ case 'discriminator':
58
+ processDiscriminatorAnnotations({
59
+ interfaceType: type,
60
+ discriminatorFieldName: directiveAnnotation.args.field,
61
+ });
62
+ break;
63
+ }
64
+ }
65
+ }
66
+ if (isUnionType(type)) {
67
+ const directiveAnnotations = getDirectives(schema, type);
68
+ let statusCodeTypeNameIndexMap;
69
+ let discriminatorField;
70
+ let discriminatorMapping;
71
+ for (const directiveAnnotation of directiveAnnotations) {
72
+ switch (directiveAnnotation.name) {
73
+ case 'statusCodeTypeName':
74
+ statusCodeTypeNameIndexMap = statusCodeTypeNameIndexMap || {};
75
+ statusCodeTypeNameIndexMap[directiveAnnotation.args.statusCode] =
76
+ directiveAnnotation.args.typeName;
77
+ break;
78
+ case 'discriminator':
79
+ discriminatorField = directiveAnnotation.args.field;
80
+ discriminatorMapping = directiveAnnotation.args.mapping;
81
+ break;
82
+ }
83
+ }
84
+ type.resolveType = getTypeResolverForAbstractType({
85
+ possibleTypes: type.getTypes(),
86
+ discriminatorField,
87
+ discriminatorMapping,
88
+ statusCodeTypeNameMap: statusCodeTypeNameIndexMap,
89
+ });
90
+ }
91
+ if (isEnumType(type)) {
92
+ const directiveAnnotations = getDirectives(schema, type);
93
+ for (const directiveAnnotation of directiveAnnotations) {
94
+ switch (directiveAnnotation.name) {
95
+ case 'typescript':
96
+ processTypeScriptAnnotations(type, directiveAnnotation.args.type);
97
+ break;
98
+ }
99
+ }
100
+ const enumValues = type.getValues();
101
+ for (const enumValue of enumValues) {
102
+ const directiveAnnotations = getDirectives(schema, enumValue);
103
+ for (const directiveAnnotation of directiveAnnotations) {
104
+ switch (directiveAnnotation.name) {
105
+ case 'enum': {
106
+ const realValue = JSON.parse(directiveAnnotation.args.value);
107
+ enumValue.value = realValue;
108
+ type._valueLookup.set(realValue, enumValue);
109
+ break;
110
+ }
111
+ }
112
+ }
113
+ }
114
+ }
115
+ if ('getFields' in type) {
116
+ const fields = type.getFields();
117
+ for (const fieldName in fields) {
118
+ const field = fields[fieldName];
119
+ const directiveAnnotations = getDirectives(schema, field);
120
+ for (const directiveAnnotation of directiveAnnotations) {
121
+ switch (directiveAnnotation.name) {
122
+ case 'resolveRoot':
123
+ processResolveRootAnnotations(field);
124
+ break;
125
+ case 'resolveRootField':
126
+ processResolveRootFieldAnnotations(field, directiveAnnotation.args.field);
127
+ break;
128
+ case 'flatten':
129
+ processFlattenAnnotations(field);
130
+ break;
131
+ case 'pubsubOperation':
132
+ processPubSubOperationAnnotations({
133
+ field: field,
134
+ pubsubTopic: directiveAnnotation.args.pubsubTopic,
135
+ globalPubsub: pubsub,
136
+ logger,
137
+ });
138
+ break;
139
+ case 'httpOperation':
140
+ addHTTPRootFieldResolver(schema, field, logger, globalFetch,
141
+ // TODO: Fix JSON parsing here for queryParams and headers
142
+ {
143
+ sourceName: directiveAnnotation.args.sourceName,
144
+ endpoint: directiveAnnotation.args.endpoint,
145
+ path: directiveAnnotation.args.path,
146
+ httpMethod: directiveAnnotation.args.httpMethod,
147
+ operationSpecificHeaders: typeof directiveAnnotation.args.operationSpecificHeaders === 'string'
148
+ ? JSON.parse(directiveAnnotation.args.operationSpecificHeaders)
149
+ : directiveAnnotation.args.operationSpecificHeaders,
150
+ isBinary: directiveAnnotation.args.isBinary,
151
+ requestBaseBody: typeof directiveAnnotation.args.requestBaseBody === 'string'
152
+ ? JSON.parse(directiveAnnotation.args.requestBaseBody)
153
+ : directiveAnnotation.args.requestBaseBody,
154
+ queryParamArgMap: typeof directiveAnnotation.args.queryParamArgMap === 'string'
155
+ ? JSON.parse(directiveAnnotation.args.queryParamArgMap)
156
+ : directiveAnnotation.args.queryParamArgMap,
157
+ queryStringOptionsByParam: typeof directiveAnnotation.args.queryStringOptionsByParam === 'string'
158
+ ? JSON.parse(directiveAnnotation.args.queryStringOptionsByParam)
159
+ : directiveAnnotation.args.queryStringOptionsByParam,
160
+ jsonApiFields: directiveAnnotation.args.jsonApiFields,
161
+ }, globalOptions);
162
+ break;
163
+ case 'responseMetadata':
164
+ processResponseMetadataAnnotations(field);
165
+ break;
166
+ case 'link':
167
+ processLinkFieldAnnotations(field, directiveAnnotation.args.defaultRootType, directiveAnnotation.args.defaultField);
168
+ break;
169
+ case 'dictionary':
170
+ processDictionaryDirective(fields, field);
171
+ }
172
+ }
173
+ }
174
+ }
175
+ }
176
+ return schema;
177
+ }
@@ -0,0 +1,27 @@
1
+ import { stringInterpolator } from '@graphql-mesh/string-interpolation';
2
+ import { createGraphQLError } from '@graphql-tools/utils';
3
+ export function processPubSubOperationAnnotations({ field, globalPubsub, pubsubTopic, logger: globalLogger, }) {
4
+ field.subscribe = function pubSubSubscribeFn(root, args, context, info) {
5
+ const logger = context?.logger || globalLogger;
6
+ const operationLogger = logger.child(`${info.parentType.name}.${field.name}`);
7
+ const pubsub = context?.pubsub || globalPubsub;
8
+ if (!pubsub) {
9
+ return createGraphQLError(`You should have PubSub defined in either the config or the context!`);
10
+ }
11
+ const interpolationData = { root, args, context, info, env: process.env };
12
+ let interpolatedPubSubTopic = stringInterpolator.parse(pubsubTopic, interpolationData);
13
+ if (interpolatedPubSubTopic.startsWith('webhook:')) {
14
+ const [, expectedMethod, expectedUrl] = interpolatedPubSubTopic.split(':');
15
+ const expectedPath = new URL(expectedUrl, 'http://localhost').pathname;
16
+ interpolatedPubSubTopic = `webhook:${expectedMethod}:${expectedPath}`;
17
+ }
18
+ operationLogger.debug(`${info.parentType.name}.${field.name} => Subscribing to pubSubTopic: ${interpolatedPubSubTopic}`);
19
+ return pubsub.asyncIterator(interpolatedPubSubTopic);
20
+ };
21
+ field.resolve = function pubSubResolver(root, args, context, info) {
22
+ const logger = context?.logger || globalLogger;
23
+ const operationLogger = logger.child(`${info.parentType.name}.${field.name}`);
24
+ operationLogger.debug('Received ', root, ' from ', pubsubTopic);
25
+ return root;
26
+ };
27
+ }
@@ -0,0 +1,20 @@
1
+ export function processRegExpAnnotations(scalar, pattern) {
2
+ function coerceString(value) {
3
+ if (value != null) {
4
+ const vStr = value.toString();
5
+ const regexp = new RegExp(pattern);
6
+ if (!regexp.test(vStr)) {
7
+ throw new Error(`${scalar.name} must match ${pattern} but given ${vStr}`);
8
+ }
9
+ return vStr;
10
+ }
11
+ }
12
+ scalar.serialize = coerceString;
13
+ scalar.parseValue = coerceString;
14
+ scalar.parseLiteral = ast => {
15
+ if ('value' in ast) {
16
+ return coerceString(ast.value);
17
+ }
18
+ return null;
19
+ };
20
+ }
@@ -0,0 +1,35 @@
1
+ import { isInputObjectType, isListType, isNonNullType, } from 'graphql';
2
+ import { sanitizeNameForGraphQL } from '@graphql-mesh/utils';
3
+ import { asArray, getDirective } from '@graphql-tools/utils';
4
+ export function resolveDataByUnionInputType(data, type, schema) {
5
+ if (data) {
6
+ if (isListType(type)) {
7
+ return asArray(data).map(elem => resolveDataByUnionInputType(elem, type.ofType, schema));
8
+ }
9
+ if (isNonNullType(type)) {
10
+ return resolveDataByUnionInputType(data, type.ofType, schema);
11
+ }
12
+ if (isInputObjectType(type)) {
13
+ const typeOneOfDirectives = getDirective(schema, type, 'oneOf');
14
+ const isOneOf = typeOneOfDirectives?.length;
15
+ const fieldMap = type.getFields();
16
+ data = asArray(data)[0];
17
+ for (const propertyName in data) {
18
+ const fieldName = sanitizeNameForGraphQL(propertyName);
19
+ const field = fieldMap[fieldName];
20
+ if (field) {
21
+ if (isOneOf) {
22
+ const resolvedData = resolveDataByUnionInputType(data[fieldName], field.type, schema);
23
+ return resolvedData;
24
+ }
25
+ const fieldData = data[fieldName];
26
+ data[fieldName] = undefined;
27
+ const fieldResolveRootFieldDirectives = getDirective(schema, field, 'resolveRootField');
28
+ const realFieldName = fieldResolveRootFieldDirectives?.[0]?.field || fieldName;
29
+ data[realFieldName] = resolveDataByUnionInputType(fieldData, field.type, schema);
30
+ }
31
+ }
32
+ }
33
+ }
34
+ return data;
35
+ }
@@ -0,0 +1,6 @@
1
+ function rootResolver(root) {
2
+ return root;
3
+ }
4
+ export function processResolveRootAnnotations(field) {
5
+ field.resolve = rootResolver;
6
+ }
@@ -0,0 +1,25 @@
1
+ import { isListType, isNonNullType } from 'graphql';
2
+ function isOriginallyListType(type) {
3
+ if (isNonNullType(type)) {
4
+ return isOriginallyListType(type.ofType);
5
+ }
6
+ return isListType(type);
7
+ }
8
+ export function processResolveRootFieldAnnotations(field, propertyName) {
9
+ if (!field.resolve || field.resolve.name === 'defaultFieldResolver') {
10
+ field.resolve = (root, args, context, info) => {
11
+ const actualFieldObj = root[propertyName];
12
+ if (actualFieldObj != null) {
13
+ const isArray = Array.isArray(actualFieldObj);
14
+ const isListType = isOriginallyListType(info.returnType);
15
+ if (isListType && !isArray) {
16
+ return [actualFieldObj];
17
+ }
18
+ else if (!isListType && isArray) {
19
+ return actualFieldObj[0];
20
+ }
21
+ }
22
+ return actualFieldObj;
23
+ };
24
+ }
25
+ }
@@ -0,0 +1,12 @@
1
+ export function processResponseMetadataAnnotations(field) {
2
+ field.resolve = function responseMetadataResolver(root) {
3
+ return {
4
+ url: root.$url,
5
+ headers: root.$response.header,
6
+ method: root.$method,
7
+ status: root.$statusCode,
8
+ statusText: root.$statusText,
9
+ body: root.$response.body,
10
+ };
11
+ };
12
+ }
@@ -0,0 +1,48 @@
1
+ import { resolvers as scalarResolvers } from 'graphql-scalars';
2
+ import { ObjMapScalar } from '@graphql-mesh/transport-common';
3
+ import { getDirectives } from '@graphql-tools/utils';
4
+ import { processLengthAnnotations } from './length.js';
5
+ import { processRegExpAnnotations } from './regexp.js';
6
+ import { processTypeScriptAnnotations } from './typescriptAnnotations.js';
7
+ export function processScalarType(schema, type) {
8
+ if (type.name in scalarResolvers) {
9
+ const actualScalar = scalarResolvers[type.name];
10
+ addExecutionLogicToScalar(type, actualScalar);
11
+ }
12
+ if (type.name === 'ObjMap') {
13
+ addExecutionLogicToScalar(type, ObjMapScalar);
14
+ }
15
+ const directiveAnnotations = getDirectives(schema, type);
16
+ for (const directiveAnnotation of directiveAnnotations) {
17
+ switch (directiveAnnotation.name) {
18
+ case 'length':
19
+ processLengthAnnotations(type, directiveAnnotation.args);
20
+ break;
21
+ case 'regexp':
22
+ processRegExpAnnotations(type, directiveAnnotation.args.pattern);
23
+ break;
24
+ case 'typescript':
25
+ processTypeScriptAnnotations(type, directiveAnnotation.args.type);
26
+ break;
27
+ }
28
+ }
29
+ }
30
+ export function addExecutionLogicToScalar(nonExecutableScalar, actualScalar) {
31
+ Object.defineProperties(nonExecutableScalar, {
32
+ serialize: {
33
+ value: actualScalar.serialize,
34
+ },
35
+ parseValue: {
36
+ value: actualScalar.parseValue,
37
+ },
38
+ parseLiteral: {
39
+ value: actualScalar.parseLiteral,
40
+ },
41
+ extensions: {
42
+ value: {
43
+ ...actualScalar.extensions,
44
+ ...nonExecutableScalar.extensions,
45
+ },
46
+ },
47
+ });
48
+ }
@@ -0,0 +1,4 @@
1
+ export function processTypeScriptAnnotations(type, typeDefinition) {
2
+ type.extensions = type.extensions || {};
3
+ type.extensions.codegenScalarType = typeDefinition;
4
+ }
package/esm/index.js ADDED
@@ -0,0 +1,15 @@
1
+ import { createDefaultExecutor } from '@graphql-mesh/transport-common';
2
+ import { processDirectives } from './directives/process';
3
+ export const getSubgraphExecutor = function getRESTSubgraphExecutor({ transportEntry, getSubgraph, fetch, pubsub, logger }) {
4
+ const preProcessedSchema = getSubgraph();
5
+ const processDirectiveOpts = {
6
+ globalFetch: fetch,
7
+ pubsub,
8
+ logger,
9
+ ...transportEntry.options,
10
+ };
11
+ const processedSchema = processDirectives(preProcessedSchema, processDirectiveOpts);
12
+ const executor = createDefaultExecutor(processedSchema);
13
+ return executor;
14
+ };
15
+ export { processDirectives } from './directives/process';
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@graphql-mesh/transport-rest",
3
+ "version": "0.0.0",
4
+ "sideEffects": false,
5
+ "peerDependencies": {
6
+ "@graphql-mesh/cross-helpers": "^0.4.1",
7
+ "@graphql-mesh/transport-common": "^0.0.0",
8
+ "@graphql-mesh/types": "^0.96.2",
9
+ "@graphql-mesh/utils": "^0.96.2",
10
+ "@graphql-tools/utils": "^10.0.12",
11
+ "@whatwg-node/fetch": "^0.9.15",
12
+ "graphql": "*",
13
+ "tslib": "^2.4.0"
14
+ },
15
+ "dependencies": {
16
+ "@graphql-mesh/string-interpolation": "^0.5.3",
17
+ "dset": "^3.1.3",
18
+ "graphql-fields": "^2.0.3",
19
+ "graphql-scalars": "^1.22.4",
20
+ "qs": "6.11.2",
21
+ "url-join": "4.0.1"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "Urigo/graphql-mesh",
26
+ "directory": "packages/transports/rest"
27
+ },
28
+ "license": "MIT",
29
+ "engines": {
30
+ "node": ">=16.0.0"
31
+ },
32
+ "main": "cjs/index.js",
33
+ "module": "esm/index.js",
34
+ "typings": "typings/index.d.ts",
35
+ "typescript": {
36
+ "definition": "typings/index.d.ts"
37
+ },
38
+ "type": "module",
39
+ "exports": {
40
+ ".": {
41
+ "require": {
42
+ "types": "./typings/index.d.cts",
43
+ "default": "./cjs/index.js"
44
+ },
45
+ "import": {
46
+ "types": "./typings/index.d.ts",
47
+ "default": "./esm/index.js"
48
+ },
49
+ "default": {
50
+ "types": "./typings/index.d.ts",
51
+ "default": "./esm/index.js"
52
+ }
53
+ },
54
+ "./package.json": "./package.json"
55
+ }
56
+ }
@@ -0,0 +1,2 @@
1
+ import { GraphQLField } from 'graphql';
2
+ export declare function processDictionaryDirective(fieldMap: Record<string, GraphQLField<any, any>>, field: GraphQLField<any, any>): void;
@@ -0,0 +1,2 @@
1
+ import { GraphQLField } from 'graphql';
2
+ export declare function processDictionaryDirective(fieldMap: Record<string, GraphQLField<any, any>>, field: GraphQLField<any, any>): void;
@@ -0,0 +1,5 @@
1
+ import { GraphQLInterfaceType } from 'graphql';
2
+ export declare function processDiscriminatorAnnotations({ interfaceType, discriminatorFieldName, }: {
3
+ interfaceType: GraphQLInterfaceType;
4
+ discriminatorFieldName: string;
5
+ }): void;
@@ -0,0 +1,5 @@
1
+ import { GraphQLInterfaceType } from 'graphql';
2
+ export declare function processDiscriminatorAnnotations({ interfaceType, discriminatorFieldName, }: {
3
+ interfaceType: GraphQLInterfaceType;
4
+ discriminatorFieldName: string;
5
+ }): void;
@@ -0,0 +1,2 @@
1
+ import { GraphQLField } from 'graphql';
2
+ export declare function processFlattenAnnotations(field: GraphQLField<any, any>): void;
@@ -0,0 +1,2 @@
1
+ import { GraphQLField } from 'graphql';
2
+ export declare function processFlattenAnnotations(field: GraphQLField<any, any>): void;
@@ -0,0 +1,7 @@
1
+ import { GraphQLObjectType, GraphQLTypeResolver } from 'graphql';
2
+ export declare function getTypeResolverForAbstractType({ possibleTypes, discriminatorField, discriminatorMapping, statusCodeTypeNameMap, }: {
3
+ possibleTypes: readonly GraphQLObjectType[];
4
+ discriminatorField?: string;
5
+ discriminatorMapping?: Record<string, string>;
6
+ statusCodeTypeNameMap?: Record<string, string>;
7
+ }): GraphQLTypeResolver<any, any>;
@@ -0,0 +1,7 @@
1
+ import { GraphQLObjectType, GraphQLTypeResolver } from 'graphql';
2
+ export declare function getTypeResolverForAbstractType({ possibleTypes, discriminatorField, discriminatorMapping, statusCodeTypeNameMap, }: {
3
+ possibleTypes: readonly GraphQLObjectType[];
4
+ discriminatorField?: string;
5
+ discriminatorMapping?: Record<string, string>;
6
+ statusCodeTypeNameMap?: Record<string, string>;
7
+ }): GraphQLTypeResolver<any, any>;
@@ -0,0 +1,28 @@
1
+ import { GraphQLField, GraphQLSchema } from 'graphql';
2
+ import { IStringifyOptions } from 'qs';
3
+ import { Logger, MeshFetch } from '@graphql-mesh/types';
4
+ type HTTPMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
5
+ export interface HTTPRootFieldResolverOpts {
6
+ sourceName: string;
7
+ endpoint: string;
8
+ path: string;
9
+ httpMethod: HTTPMethod;
10
+ operationSpecificHeaders: Record<string, string>;
11
+ isBinary: boolean;
12
+ requestBaseBody: any;
13
+ queryParamArgMap: Record<string, string>;
14
+ queryStringOptionsByParam: Record<string, IStringifyOptions & {
15
+ destructObject?: boolean;
16
+ }>;
17
+ jsonApiFields: boolean;
18
+ }
19
+ export interface GlobalOptions {
20
+ sourceName: string;
21
+ endpoint: string;
22
+ timeout: number;
23
+ operationHeaders: Record<string, string>;
24
+ queryStringOptions: IStringifyOptions;
25
+ queryParams: Record<string, string | number | boolean>;
26
+ }
27
+ export declare function addHTTPRootFieldResolver(schema: GraphQLSchema, field: GraphQLField<any, any>, globalLogger: Logger, globalFetch: MeshFetch, { path, operationSpecificHeaders, httpMethod, isBinary, requestBaseBody, queryParamArgMap, queryStringOptionsByParam, jsonApiFields, }: HTTPRootFieldResolverOpts, { sourceName, endpoint, timeout, operationHeaders: globalOperationHeaders, queryStringOptions: globalQueryStringOptions, queryParams: globalQueryParams, }: GlobalOptions): void;
28
+ export {};
@@ -0,0 +1,28 @@
1
+ import { GraphQLField, GraphQLSchema } from 'graphql';
2
+ import { IStringifyOptions } from 'qs';
3
+ import { Logger, MeshFetch } from '@graphql-mesh/types';
4
+ type HTTPMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
5
+ export interface HTTPRootFieldResolverOpts {
6
+ sourceName: string;
7
+ endpoint: string;
8
+ path: string;
9
+ httpMethod: HTTPMethod;
10
+ operationSpecificHeaders: Record<string, string>;
11
+ isBinary: boolean;
12
+ requestBaseBody: any;
13
+ queryParamArgMap: Record<string, string>;
14
+ queryStringOptionsByParam: Record<string, IStringifyOptions & {
15
+ destructObject?: boolean;
16
+ }>;
17
+ jsonApiFields: boolean;
18
+ }
19
+ export interface GlobalOptions {
20
+ sourceName: string;
21
+ endpoint: string;
22
+ timeout: number;
23
+ operationHeaders: Record<string, string>;
24
+ queryStringOptions: IStringifyOptions;
25
+ queryParams: Record<string, string | number | boolean>;
26
+ }
27
+ export declare function addHTTPRootFieldResolver(schema: GraphQLSchema, field: GraphQLField<any, any>, globalLogger: Logger, globalFetch: MeshFetch, { path, operationSpecificHeaders, httpMethod, isBinary, requestBaseBody, queryParamArgMap, queryStringOptionsByParam, jsonApiFields, }: HTTPRootFieldResolverOpts, { sourceName, endpoint, timeout, operationHeaders: globalOperationHeaders, queryStringOptions: globalQueryStringOptions, queryParams: globalQueryParams, }: GlobalOptions): void;
28
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare function isFileUpload(obj: any): obj is {
2
+ createReadStream: () => AsyncIterable<Uint8Array>;
3
+ mimetype: string;
4
+ };
@@ -0,0 +1,4 @@
1
+ export declare function isFileUpload(obj: any): obj is {
2
+ createReadStream: () => AsyncIterable<Uint8Array>;
3
+ mimetype: string;
4
+ };
@@ -0,0 +1,2 @@
1
+ import { GraphQLResolveInfo } from 'graphql';
2
+ export declare function getJsonApiFieldsQuery(info: GraphQLResolveInfo): string;
@@ -0,0 +1,2 @@
1
+ import { GraphQLResolveInfo } from 'graphql';
2
+ export declare function getJsonApiFieldsQuery(info: GraphQLResolveInfo): string;
@@ -0,0 +1,5 @@
1
+ import { GraphQLScalarType } from 'graphql';
2
+ export declare function processLengthAnnotations(scalar: GraphQLScalarType, { min: minLength, max: maxLength, }: {
3
+ min?: number;
4
+ max?: number;
5
+ }): void;
@@ -0,0 +1,5 @@
1
+ import { GraphQLScalarType } from 'graphql';
2
+ export declare function processLengthAnnotations(scalar: GraphQLScalarType, { min: minLength, max: maxLength, }: {
3
+ min?: number;
4
+ max?: number;
5
+ }): void;
@@ -0,0 +1,2 @@
1
+ import { GraphQLField } from 'graphql';
2
+ export declare function processLinkFieldAnnotations(field: GraphQLField<any, any>, defaultRootTypeName: string, defaultFieldName: string): void;
@@ -0,0 +1,2 @@
1
+ import { GraphQLField } from 'graphql';
2
+ export declare function processLinkFieldAnnotations(field: GraphQLField<any, any>, defaultRootTypeName: string, defaultFieldName: string): void;
@@ -0,0 +1,12 @@
1
+ import { GraphQLSchema } from 'graphql';
2
+ import { Logger, MeshFetch, MeshPubSub } from '@graphql-mesh/types';
3
+ export interface ProcessDirectiveArgs {
4
+ pubsub?: MeshPubSub;
5
+ logger?: Logger;
6
+ globalFetch?: MeshFetch;
7
+ endpoint?: string;
8
+ timeout?: number;
9
+ operationHeaders?: Record<string, string>;
10
+ queryParams?: Record<string, any>;
11
+ }
12
+ export declare function processDirectives(schema: GraphQLSchema, { globalFetch, logger, pubsub, ...extraGlobalOptions }?: ProcessDirectiveArgs): GraphQLSchema;
@@ -0,0 +1,12 @@
1
+ import { GraphQLSchema } from 'graphql';
2
+ import { Logger, MeshFetch, MeshPubSub } from '@graphql-mesh/types';
3
+ export interface ProcessDirectiveArgs {
4
+ pubsub?: MeshPubSub;
5
+ logger?: Logger;
6
+ globalFetch?: MeshFetch;
7
+ endpoint?: string;
8
+ timeout?: number;
9
+ operationHeaders?: Record<string, string>;
10
+ queryParams?: Record<string, any>;
11
+ }
12
+ export declare function processDirectives(schema: GraphQLSchema, { globalFetch, logger, pubsub, ...extraGlobalOptions }?: ProcessDirectiveArgs): GraphQLSchema;
@@ -0,0 +1,10 @@
1
+ import { GraphQLField } from 'graphql';
2
+ import { Logger, MeshPubSub } from '@graphql-mesh/types';
3
+ interface ProcessPubSubOperationAnnotationsOpts {
4
+ field: GraphQLField<any, any>;
5
+ globalPubsub: MeshPubSub;
6
+ pubsubTopic: string;
7
+ logger: Logger;
8
+ }
9
+ export declare function processPubSubOperationAnnotations({ field, globalPubsub, pubsubTopic, logger: globalLogger, }: ProcessPubSubOperationAnnotationsOpts): void;
10
+ export {};
@@ -0,0 +1,10 @@
1
+ import { GraphQLField } from 'graphql';
2
+ import { Logger, MeshPubSub } from '@graphql-mesh/types';
3
+ interface ProcessPubSubOperationAnnotationsOpts {
4
+ field: GraphQLField<any, any>;
5
+ globalPubsub: MeshPubSub;
6
+ pubsubTopic: string;
7
+ logger: Logger;
8
+ }
9
+ export declare function processPubSubOperationAnnotations({ field, globalPubsub, pubsubTopic, logger: globalLogger, }: ProcessPubSubOperationAnnotationsOpts): void;
10
+ export {};
@@ -0,0 +1,2 @@
1
+ import { GraphQLScalarType } from 'graphql';
2
+ export declare function processRegExpAnnotations(scalar: GraphQLScalarType, pattern: string): void;
@@ -0,0 +1,2 @@
1
+ import { GraphQLScalarType } from 'graphql';
2
+ export declare function processRegExpAnnotations(scalar: GraphQLScalarType, pattern: string): void;