@graphql-mesh/openapi 1.0.0-alpha-20220804093904-8e2e41f7f → 1.0.0-alpha-20230420220344-25b6b92bf
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 +97 -0
- package/cjs/package.json +1 -0
- package/esm/index.js +94 -0
- package/package.json +27 -32
- package/typings/index.d.cts +18 -0
- package/typings/index.d.ts +18 -0
- package/index.d.ts +0 -13
- package/index.js +0 -5020
- package/index.mjs +0 -5016
- package/openapi-to-graphql/auth_builder.d.ts +0 -24
- package/openapi-to-graphql/graphql_tools.d.ts +0 -8
- package/openapi-to-graphql/index.d.ts +0 -39
- package/openapi-to-graphql/oas_3_tools.d.ts +0 -208
- package/openapi-to-graphql/preprocessor.d.ts +0 -18
- package/openapi-to-graphql/resolver_builder.d.ts +0 -60
- package/openapi-to-graphql/schema_builder.d.ts +0 -36
- package/openapi-to-graphql/types/graphql.d.ts +0 -31
- package/openapi-to-graphql/types/oas2.d.ts +0 -10
- package/openapi-to-graphql/types/oas3.d.ts +0 -243
- package/openapi-to-graphql/types/operation.d.ts +0 -122
- package/openapi-to-graphql/types/options.d.ts +0 -251
- package/openapi-to-graphql/types/preprocessing_data.d.ts +0 -71
- package/openapi-to-graphql/utils.d.ts +0 -61
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Functions to create viewers that allow users to pass credentials to resolve
|
|
3
|
-
* functions used by OpenAPI-to-GraphQL.
|
|
4
|
-
*/
|
|
5
|
-
import { GraphQLObjectType, GraphQLFieldResolver } from 'graphql';
|
|
6
|
-
import { Args, GraphQLOperationType } from './types/graphql';
|
|
7
|
-
import { PreprocessingData } from './types/preprocessing_data';
|
|
8
|
-
import { Logger } from '@graphql-mesh/types';
|
|
9
|
-
declare type Viewer<TSource, TContext, TArgs> = {
|
|
10
|
-
type: GraphQLObjectType;
|
|
11
|
-
resolve: GraphQLFieldResolver<TSource, TContext, TArgs>;
|
|
12
|
-
args: Args;
|
|
13
|
-
description: string;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Load the field object in the appropriate root object
|
|
17
|
-
*
|
|
18
|
-
* i.e. inside either rootQueryFields/rootMutationFields or inside
|
|
19
|
-
* rootQueryFields/rootMutationFields for further processing
|
|
20
|
-
*/
|
|
21
|
-
export declare function createAndLoadViewer<TSource, TContext, TArgs>(queryFields: any, operationType: GraphQLOperationType, data: PreprocessingData<TSource, TContext, TArgs>, includeHttpDetails: boolean, logger: Logger): {
|
|
22
|
-
[key: string]: Viewer<TSource, TContext, TArgs>;
|
|
23
|
-
};
|
|
24
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines the functions exposed by OpenAPI-to-GraphQL.
|
|
3
|
-
*
|
|
4
|
-
* Some general notes:
|
|
5
|
-
*
|
|
6
|
-
* - GraphQL interfaces rely on sanitized strings for (input) object type names
|
|
7
|
-
* and fields. We perform sanitization only when assigning (field-) names, but
|
|
8
|
-
* keep keys in the OAS otherwise as-is, to ensure that inner-OAS references
|
|
9
|
-
* work as expected.
|
|
10
|
-
*
|
|
11
|
-
* - GraphQL (input) object types must have a unique name. Thus, sometimes Input
|
|
12
|
-
* object types and object types need separate names, despite them having the
|
|
13
|
-
* same structure. We thus append 'Input' to every input object type's name
|
|
14
|
-
* as a convention.
|
|
15
|
-
*
|
|
16
|
-
* - To pass data between resolve functions, OpenAPI-to-GraphQL uses a _openAPIToGraphQL object
|
|
17
|
-
* returned by every resolver in addition to its original data (OpenAPI-to-GraphQL does
|
|
18
|
-
* not use the context to do so, which is an anti-pattern according to
|
|
19
|
-
* https://github.com/graphql/graphql-js/issues/953).
|
|
20
|
-
*
|
|
21
|
-
* - OpenAPI-to-GraphQL can handle basic authentication and API key-based authentication
|
|
22
|
-
* through GraphQL. To do this, OpenAPI-to-GraphQL creates two new intermediate Object
|
|
23
|
-
* Types called QueryViewer and MutationViewer that take as input security
|
|
24
|
-
* credentials and pass them on using the _openAPIToGraphQL object to other resolve
|
|
25
|
-
* functions.
|
|
26
|
-
*/
|
|
27
|
-
import { Options, Report } from './types/options';
|
|
28
|
-
import { Oas3 } from './types/oas3';
|
|
29
|
-
import { GraphQLSchema } from 'graphql';
|
|
30
|
-
declare type Result = {
|
|
31
|
-
schema: GraphQLSchema;
|
|
32
|
-
report: Report;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Creates a GraphQL interface from the given OpenAPI Specification (2 or 3).
|
|
36
|
-
*/
|
|
37
|
-
export declare function createGraphQLSchema<TSource, TContext, TArgs>(oasOrOass: Oas3 | Oas3[], options?: Options<TSource, TContext, TArgs>): Promise<Result>;
|
|
38
|
-
export { sanitize, CaseStyle } from './oas_3_tools';
|
|
39
|
-
export { GraphQLOperationType } from './types/graphql';
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility functions around the OpenAPI Specification 3.
|
|
3
|
-
*/
|
|
4
|
-
import { Oas2 } from './types/oas2';
|
|
5
|
-
import { Operation } from './types/operation';
|
|
6
|
-
import { Oas3, ServerObject, ParameterObject, SchemaObject, OperationObject, ResponseObject, PathItemObject, RequestBodyObject, ReferenceObject, LinkObject, SecuritySchemeObject } from './types/oas3';
|
|
7
|
-
import { PreprocessingData, ProcessedSecurityScheme } from './types/preprocessing_data';
|
|
8
|
-
import { InternalOptions } from './types/options';
|
|
9
|
-
import { Logger } from '@graphql-mesh/types';
|
|
10
|
-
export declare type SchemaNames = {
|
|
11
|
-
fromRef?: string;
|
|
12
|
-
fromSchema?: string;
|
|
13
|
-
fromPath?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Used when the preferred name is known, i.e. a new data def does not need to
|
|
16
|
-
* be created
|
|
17
|
-
*/
|
|
18
|
-
preferred?: string;
|
|
19
|
-
};
|
|
20
|
-
export declare type RequestSchemaAndNames = {
|
|
21
|
-
payloadContentType?: string;
|
|
22
|
-
payloadSchema?: SchemaObject | ReferenceObject;
|
|
23
|
-
payloadSchemaNames?: SchemaNames;
|
|
24
|
-
payloadRequired: boolean;
|
|
25
|
-
};
|
|
26
|
-
export declare type ResponseSchemaAndNames = {
|
|
27
|
-
responseContentType?: string;
|
|
28
|
-
responseSchema?: SchemaObject | ReferenceObject;
|
|
29
|
-
responseSchemaNames?: SchemaNames;
|
|
30
|
-
statusCode?: string;
|
|
31
|
-
};
|
|
32
|
-
export declare enum HTTP_METHODS {
|
|
33
|
-
'get' = "get",
|
|
34
|
-
'put' = "put",
|
|
35
|
-
'post' = "post",
|
|
36
|
-
'patch' = "patch",
|
|
37
|
-
'delete' = "delete",
|
|
38
|
-
'options' = "options",
|
|
39
|
-
'head' = "head"
|
|
40
|
-
}
|
|
41
|
-
export declare const SUCCESS_STATUS_RX: RegExp;
|
|
42
|
-
export declare const CONTENT_TYPE_JSON_RX: RegExp;
|
|
43
|
-
/**
|
|
44
|
-
* Given an HTTP method, convert it to the HTTP_METHODS enum
|
|
45
|
-
*/
|
|
46
|
-
export declare function methodToHttpMethod(method: string): HTTP_METHODS;
|
|
47
|
-
/**
|
|
48
|
-
* Resolves on a validated OAS 3 for the given spec (OAS 2 or OAS 3), or rejects
|
|
49
|
-
* if errors occur.
|
|
50
|
-
*/
|
|
51
|
-
export declare function getValidOAS3(spec: Oas2 | Oas3): Promise<Oas3>;
|
|
52
|
-
/**
|
|
53
|
-
* Counts the number of operations in an OAS.
|
|
54
|
-
*/
|
|
55
|
-
export declare function countOperations(oas: Oas3): number;
|
|
56
|
-
/**
|
|
57
|
-
* Counts the number of operations that translate to queries in an OAS.
|
|
58
|
-
*/
|
|
59
|
-
export declare function countOperationsQuery(oas: Oas3): number;
|
|
60
|
-
/**
|
|
61
|
-
* Counts the number of operations that translate to mutations in an OAS.
|
|
62
|
-
*/
|
|
63
|
-
export declare function countOperationsMutation(oas: Oas3): number;
|
|
64
|
-
/**
|
|
65
|
-
* Counts the number of operations that translate to subscriptions in an OAS.
|
|
66
|
-
*/
|
|
67
|
-
export declare function countOperationsSubscription(oas: Oas3): number;
|
|
68
|
-
/**
|
|
69
|
-
* Counts the number of operations with a payload definition in an OAS.
|
|
70
|
-
*/
|
|
71
|
-
export declare function countOperationsWithPayload(oas: Oas3): number;
|
|
72
|
-
/**
|
|
73
|
-
* Resolves the given reference in the given object.
|
|
74
|
-
*/
|
|
75
|
-
export declare function resolveRef(ref: string, oas: Oas3): any;
|
|
76
|
-
/**
|
|
77
|
-
* Returns the base URL to use for the given operation.
|
|
78
|
-
*/
|
|
79
|
-
export declare function getBaseUrl(operation: Operation, logger: Logger): string;
|
|
80
|
-
/**
|
|
81
|
-
* Returns object/array/scalar where all object keys (if applicable) are
|
|
82
|
-
* sanitized.
|
|
83
|
-
*/
|
|
84
|
-
export declare function sanitizeObjectKeys(obj: any, // obj does not necessarily need to be an object
|
|
85
|
-
caseStyle?: CaseStyle): any;
|
|
86
|
-
/**
|
|
87
|
-
* Desanitizes keys in given object by replacing them with the keys stored in
|
|
88
|
-
* the given mapping.
|
|
89
|
-
*/
|
|
90
|
-
export declare function desanitizeObjectKeys(obj: object | Array<any>, mapping?: object): object | Array<any>;
|
|
91
|
-
/**
|
|
92
|
-
* Returns the GraphQL type that the provided schema should be made into
|
|
93
|
-
*
|
|
94
|
-
* Does not consider allOf, anyOf, oneOf, or not (handled separately)
|
|
95
|
-
*/
|
|
96
|
-
export declare function getSchemaTargetGraphQLType<TSource, TContext, TArgs>(schema: SchemaObject, data: PreprocessingData<TSource, TContext, TArgs>): string | null;
|
|
97
|
-
/**
|
|
98
|
-
* Infers a resource name from the given URL path.
|
|
99
|
-
*
|
|
100
|
-
* For example, turns "/users/{userId}/car" into "userCar".
|
|
101
|
-
*/
|
|
102
|
-
export declare function inferResourceNameFromPath(path: string): string;
|
|
103
|
-
/**
|
|
104
|
-
* Returns JSON-compatible schema required by the given operation
|
|
105
|
-
*/
|
|
106
|
-
export declare function getRequestBodyObject(operation: OperationObject, oas: Oas3): {
|
|
107
|
-
payloadContentType: string;
|
|
108
|
-
requestBodyObject: RequestBodyObject;
|
|
109
|
-
} | null;
|
|
110
|
-
/**
|
|
111
|
-
* Returns the request schema (if any) for the given operation,
|
|
112
|
-
* a dictionary of names from different sources (if available), and whether the
|
|
113
|
-
* request schema is required for the operation.
|
|
114
|
-
*/
|
|
115
|
-
export declare function getRequestSchemaAndNames(path: string, operation: OperationObject, oas: Oas3): RequestSchemaAndNames;
|
|
116
|
-
/**
|
|
117
|
-
* Returns JSON-compatible schema produced by the given operation
|
|
118
|
-
*/
|
|
119
|
-
export declare function getResponseObject(operation: OperationObject, statusCode: string, oas: Oas3): {
|
|
120
|
-
responseContentType: string;
|
|
121
|
-
responseObject: ResponseObject;
|
|
122
|
-
} | null;
|
|
123
|
-
/**
|
|
124
|
-
* Returns the response schema for the given operation,
|
|
125
|
-
* a successful status code, and a dictionary of names from different sources
|
|
126
|
-
* (if available).
|
|
127
|
-
*/
|
|
128
|
-
export declare function getResponseSchemaAndNames<TSource, TContext, TArgs>(path: string, method: HTTP_METHODS, operation: OperationObject, oas: Oas3, data: PreprocessingData<TSource, TContext, TArgs>, options: InternalOptions<TSource, TContext, TArgs>): ResponseSchemaAndNames;
|
|
129
|
-
/**
|
|
130
|
-
* Returns a success status code for the given operation
|
|
131
|
-
*/
|
|
132
|
-
export declare function getResponseStatusCode<TSource, TContext, TArgs>(path: string, method: string, operation: OperationObject, oas: Oas3, data: PreprocessingData<TSource, TContext, TArgs>, logger: Logger): string | void;
|
|
133
|
-
/**
|
|
134
|
-
* Returns a hash containing the links in the given operation.
|
|
135
|
-
*/
|
|
136
|
-
export declare function getLinks<TSource, TContext, TArgs>(path: string, method: HTTP_METHODS, operation: OperationObject, oas: Oas3, data: PreprocessingData<TSource, TContext, TArgs>, logger: Logger): {
|
|
137
|
-
[key: string]: LinkObject;
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* Returns the list of parameters in the given operation.
|
|
141
|
-
*/
|
|
142
|
-
export declare function getParameters(path: string, method: HTTP_METHODS, operation: OperationObject, pathItem: PathItemObject, oas: Oas3, logger: Logger): ParameterObject[];
|
|
143
|
-
/**
|
|
144
|
-
* Returns an array of server objects for the operation at the given path and
|
|
145
|
-
* method. Considers in the following order: global server definitions,
|
|
146
|
-
* definitions at the path item, definitions at the operation, or the OAS
|
|
147
|
-
* default.
|
|
148
|
-
*/
|
|
149
|
-
export declare function getServers(operation: OperationObject, pathItem: PathItemObject, oas: Oas3): ServerObject[];
|
|
150
|
-
/**
|
|
151
|
-
* Returns a map of Security Scheme definitions, identified by keys. Resolves
|
|
152
|
-
* possible references.
|
|
153
|
-
*/
|
|
154
|
-
export declare function getSecuritySchemes(oas: Oas3): {
|
|
155
|
-
[key: string]: SecuritySchemeObject;
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* Returns the list of sanitized keys of non-OAuth2 security schemes
|
|
159
|
-
* required by the operation at the given path and method.
|
|
160
|
-
*/
|
|
161
|
-
export declare function getSecurityRequirements(operation: OperationObject, securitySchemes: {
|
|
162
|
-
[key: string]: ProcessedSecurityScheme;
|
|
163
|
-
}, oas: Oas3): string[];
|
|
164
|
-
export declare enum CaseStyle {
|
|
165
|
-
simple = 0,
|
|
166
|
-
PascalCase = 1,
|
|
167
|
-
camelCase = 2,
|
|
168
|
-
ALL_CAPS = 3
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* First sanitizes given string and then also camel-cases it.
|
|
172
|
-
*/
|
|
173
|
-
export declare function sanitize(str: string, caseStyle: CaseStyle): string;
|
|
174
|
-
/**
|
|
175
|
-
* Sanitizes the given string and stores the sanitized-to-original mapping in
|
|
176
|
-
* the given mapping.
|
|
177
|
-
*/
|
|
178
|
-
export declare function storeSaneName(saneStr: string, str: string, mapping: {
|
|
179
|
-
[key: string]: string;
|
|
180
|
-
}, logger: Logger): string;
|
|
181
|
-
/**
|
|
182
|
-
* Stringifies and possibly trims the given string to the provided length.
|
|
183
|
-
*/
|
|
184
|
-
export declare function trim(str: string, length: number): string;
|
|
185
|
-
/**
|
|
186
|
-
* Determines if the given "method" is indeed an operation. Alternatively, the
|
|
187
|
-
* method could point to other types of information (e.g., parameters, servers).
|
|
188
|
-
*/
|
|
189
|
-
export declare function isHttpMethod(method: string): boolean;
|
|
190
|
-
/**
|
|
191
|
-
* Formats a string that describes an operation in the form:
|
|
192
|
-
* {name of OAS} {HTTP method in ALL_CAPS} {operation path}
|
|
193
|
-
*
|
|
194
|
-
* Also used in preprocessing.ts where Operation objects are being constructed
|
|
195
|
-
*/
|
|
196
|
-
export declare function formatOperationString(method: string, path: string, title?: string): string;
|
|
197
|
-
/**
|
|
198
|
-
* Capitalizes a given string
|
|
199
|
-
*/
|
|
200
|
-
export declare function capitalize(str: string): string;
|
|
201
|
-
/**
|
|
202
|
-
* Uncapitalizes a given string
|
|
203
|
-
*/
|
|
204
|
-
export declare function uncapitalize(str: string): string;
|
|
205
|
-
/**
|
|
206
|
-
* For operations that do not have an operationId, generate one
|
|
207
|
-
*/
|
|
208
|
-
export declare function generateOperationId(method: HTTP_METHODS, path: string): string;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Oas3, LinkObject, SchemaObject } from './types/oas3';
|
|
2
|
-
import { InternalOptions } from './types/options';
|
|
3
|
-
import { DataDefinition } from './types/operation';
|
|
4
|
-
import { PreprocessingData } from './types/preprocessing_data';
|
|
5
|
-
import * as Oas3Tools from './oas_3_tools';
|
|
6
|
-
import { Logger } from '@graphql-mesh/types';
|
|
7
|
-
/**
|
|
8
|
-
* Extract information from the OAS and put it inside a data structure that
|
|
9
|
-
* is easier for OpenAPI-to-GraphQL to use
|
|
10
|
-
*/
|
|
11
|
-
export declare function preprocessOas<TSource, TContext, TArgs>(oass: Oas3[], options: InternalOptions<TSource, TContext, TArgs>): PreprocessingData<TSource, TContext, TArgs>;
|
|
12
|
-
/**
|
|
13
|
-
* Method to either create a new or reuse an existing, centrally stored data
|
|
14
|
-
* definition.
|
|
15
|
-
*/
|
|
16
|
-
export declare function createDataDef<TSource, TContext, TArgs>(names: Oas3Tools.SchemaNames, schema: SchemaObject, isInputObjectType: boolean, data: PreprocessingData<TSource, TContext, TArgs>, oas: Oas3, logger: Logger, links?: {
|
|
17
|
-
[key: string]: LinkObject;
|
|
18
|
-
}): DataDefinition;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Functions to create resolve functions.
|
|
3
|
-
*/
|
|
4
|
-
import { ParameterObject } from './types/oas3';
|
|
5
|
-
import { Operation } from './types/operation';
|
|
6
|
-
import { ResolveFunction, SubscriptionContext } from './types/graphql';
|
|
7
|
-
import { PreprocessingData } from './types/preprocessing_data';
|
|
8
|
-
import { GraphQLFieldResolver } from 'graphql';
|
|
9
|
-
import { ConnectOptions, RequestOptions } from './types/options';
|
|
10
|
-
import { Logger, MeshPubSub } from '@graphql-mesh/types';
|
|
11
|
-
declare type GetResolverParams<TSource, TContext, TArgs> = {
|
|
12
|
-
operation: Operation;
|
|
13
|
-
argsFromLink?: Record<string, string>;
|
|
14
|
-
payloadName?: string;
|
|
15
|
-
responseName?: string;
|
|
16
|
-
data: PreprocessingData<TSource, TContext, TArgs>;
|
|
17
|
-
baseUrl?: string;
|
|
18
|
-
requestOptions?: RequestOptions<TSource, TContext, TArgs>;
|
|
19
|
-
fetch?: (input: RequestInfo, init?: RequestInit, ctx?: TContext) => Promise<Response>;
|
|
20
|
-
qs?: Record<string, string>;
|
|
21
|
-
logger: Logger;
|
|
22
|
-
};
|
|
23
|
-
declare type GetSubscribeParams<TSource, TContext, TArgs> = {
|
|
24
|
-
operation: Operation;
|
|
25
|
-
argsFromLink?: {
|
|
26
|
-
[key: string]: string;
|
|
27
|
-
};
|
|
28
|
-
payloadName?: string;
|
|
29
|
-
data: PreprocessingData<TSource, TContext, TArgs>;
|
|
30
|
-
baseUrl?: string;
|
|
31
|
-
connectOptions?: ConnectOptions;
|
|
32
|
-
pubsub: MeshPubSub;
|
|
33
|
-
logger: Logger;
|
|
34
|
-
};
|
|
35
|
-
export declare function getSubscribe<TSource, TContext, TArgs>({ operation, payloadName, data, baseUrl, connectOptions, pubsub, logger, }: GetSubscribeParams<TSource, TContext, TArgs>): GraphQLFieldResolver<TSource, SubscriptionContext, TArgs>;
|
|
36
|
-
export declare function getPublishResolver<TSource, TContext, TArgs>({ operation, responseName, data, logger, }: GetResolverParams<TSource, TContext, TArgs>): GraphQLFieldResolver<TSource, TContext, TArgs>;
|
|
37
|
-
export declare type ResolverMiddleware<TSource, TContext, TArgs> = (getResolverParams: () => GetResolverParams<TSource, TContext, TArgs>, factory: ResolverFactory) => ResolveFunction;
|
|
38
|
-
declare type ResolverFactory = typeof getResolver;
|
|
39
|
-
/**
|
|
40
|
-
* Creates and returns a resolver function that performs API requests for the
|
|
41
|
-
* given GraphQL query
|
|
42
|
-
*/
|
|
43
|
-
export declare function getResolver<TSource, TContext, TArgs>(getResolverParams: () => GetResolverParams<TSource, TContext, TArgs>, logger: Logger): ResolveFunction;
|
|
44
|
-
/**
|
|
45
|
-
* Extracts data from the GraphQL arguments of a particular field
|
|
46
|
-
*
|
|
47
|
-
* Replaces the path parameter in the given path with values in the given args.
|
|
48
|
-
* Furthermore adds the query parameters for a request.
|
|
49
|
-
*/
|
|
50
|
-
export declare function extractRequestDataFromArgs<TSource, TContext, TArgs>(path: string, parameters: ParameterObject[], args: TArgs, // NOTE: argument keys are sanitized!
|
|
51
|
-
data: PreprocessingData<TSource, TContext, TArgs>, logger: Logger): {
|
|
52
|
-
path: string;
|
|
53
|
-
qs: {
|
|
54
|
-
[key: string]: string;
|
|
55
|
-
};
|
|
56
|
-
headers: {
|
|
57
|
-
[key: string]: string;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Functions to translate JSON schema to GraphQL (input) object types.
|
|
3
|
-
*/
|
|
4
|
-
import { PreprocessingData } from './types/preprocessing_data';
|
|
5
|
-
import { Operation, DataDefinition } from './types/operation';
|
|
6
|
-
import { ParameterObject } from './types/oas3';
|
|
7
|
-
import { Args, GraphQLType } from './types/graphql';
|
|
8
|
-
import { Logger } from '@graphql-mesh/types';
|
|
9
|
-
declare type GetArgsParams<TSource, TContext, TArgs> = {
|
|
10
|
-
requestPayloadDef?: DataDefinition;
|
|
11
|
-
parameters: ParameterObject[];
|
|
12
|
-
operation?: Operation;
|
|
13
|
-
data: PreprocessingData<TSource, TContext, TArgs>;
|
|
14
|
-
includeHttpDetails: boolean;
|
|
15
|
-
logger: Logger;
|
|
16
|
-
};
|
|
17
|
-
declare type CreateOrReuseComplexTypeParams<TSource, TContext, TArgs> = {
|
|
18
|
-
def: DataDefinition;
|
|
19
|
-
operation?: Operation;
|
|
20
|
-
iteration?: number;
|
|
21
|
-
isInputObjectType?: boolean;
|
|
22
|
-
data: PreprocessingData<TSource, TContext, TArgs>;
|
|
23
|
-
includeHttpDetails: boolean;
|
|
24
|
-
logger: Logger;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Creates and returns a GraphQL type for the given JSON schema.
|
|
28
|
-
*/
|
|
29
|
-
export declare function getGraphQLType<TSource, TContext, TArgs>({ def, operation, data, iteration, isInputObjectType, includeHttpDetails, logger, }: CreateOrReuseComplexTypeParams<TSource, TContext, TArgs>): GraphQLType;
|
|
30
|
-
/**
|
|
31
|
-
* Creates the arguments for resolving a field
|
|
32
|
-
*
|
|
33
|
-
* Arguments that are provided via options will be ignored
|
|
34
|
-
*/
|
|
35
|
-
export declare function getArgs<TSource, TContext, TArgs>({ requestPayloadDef, parameters, operation, data, includeHttpDetails, logger, }: GetArgsParams<TSource, TContext, TArgs>): Args;
|
|
36
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Custom type definitions for GraphQL.
|
|
3
|
-
*/
|
|
4
|
-
import { GraphQLObjectType, GraphQLScalarType, GraphQLInputObjectType, GraphQLList, GraphQLEnumType, GraphQLUnionType, GraphQLFieldResolver, GraphQLResolveInfo } from 'graphql';
|
|
5
|
-
export declare enum GraphQLOperationType {
|
|
6
|
-
Query = 0,
|
|
7
|
-
Mutation = 1,
|
|
8
|
-
Subscription = 2
|
|
9
|
-
}
|
|
10
|
-
export declare type GraphQLType = GraphQLObjectType | GraphQLInputObjectType | GraphQLList<any> | GraphQLUnionType | GraphQLEnumType | GraphQLScalarType;
|
|
11
|
-
declare type Arg = {
|
|
12
|
-
type: any;
|
|
13
|
-
description?: string;
|
|
14
|
-
};
|
|
15
|
-
export declare type Args = {
|
|
16
|
-
[key: string]: Arg;
|
|
17
|
-
};
|
|
18
|
-
export declare type SubscriptionContext = {
|
|
19
|
-
pubsub: any;
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
};
|
|
22
|
-
export declare type SubscriptionIterator = (root: object, args: object, context: SubscriptionContext, info?: object) => AsyncIterable<string | string[]>;
|
|
23
|
-
export declare type Field<TSource, TContext, TArgs> = {
|
|
24
|
-
type: GraphQLType;
|
|
25
|
-
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>;
|
|
26
|
-
subscribe?: GraphQLFieldResolver<TSource, SubscriptionContext, TArgs>;
|
|
27
|
-
args?: Args;
|
|
28
|
-
description: string;
|
|
29
|
-
};
|
|
30
|
-
export declare type ResolveFunction = (root: any, args: any, ctx: any, info: GraphQLResolveInfo) => Promise<any> | any;
|
|
31
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for the OpenAPI specification 2.0 (Swagger).
|
|
3
|
-
*
|
|
4
|
-
* NOTE: We do not really care about OpenAPI specification 2.0 / Swagger, as we
|
|
5
|
-
* translate it to Oas3 immediately anyways.
|
|
6
|
-
*/
|
|
7
|
-
export declare type Oas2 = {
|
|
8
|
-
swagger: string;
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
};
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for the OpenAPI Specification 3.
|
|
3
|
-
*/
|
|
4
|
-
declare type ExternalDocumentationObject = {
|
|
5
|
-
description?: string;
|
|
6
|
-
url: string;
|
|
7
|
-
};
|
|
8
|
-
export declare type SchemaObject = {
|
|
9
|
-
$ref?: string;
|
|
10
|
-
title?: string;
|
|
11
|
-
type?: 'string' | 'number' | 'object' | 'array' | 'boolean' | 'integer';
|
|
12
|
-
format?: string;
|
|
13
|
-
nullable?: boolean;
|
|
14
|
-
description?: string;
|
|
15
|
-
properties?: {
|
|
16
|
-
[key: string]: SchemaObject | ReferenceObject;
|
|
17
|
-
};
|
|
18
|
-
required?: string[];
|
|
19
|
-
default?: any;
|
|
20
|
-
additionalProperties?: SchemaObject | ReferenceObject;
|
|
21
|
-
items?: SchemaObject | ReferenceObject;
|
|
22
|
-
additionalItems?: boolean | string[];
|
|
23
|
-
enum?: string[];
|
|
24
|
-
allOf?: (SchemaObject | ReferenceObject)[];
|
|
25
|
-
anyOf?: (SchemaObject | ReferenceObject)[];
|
|
26
|
-
oneOf?: (SchemaObject | ReferenceObject)[];
|
|
27
|
-
not?: (SchemaObject | ReferenceObject)[];
|
|
28
|
-
};
|
|
29
|
-
export declare type ReferenceObject = {
|
|
30
|
-
$ref: string;
|
|
31
|
-
};
|
|
32
|
-
declare type ExampleObject = {
|
|
33
|
-
summary?: string;
|
|
34
|
-
description?: string;
|
|
35
|
-
value?: any;
|
|
36
|
-
externalValue?: string;
|
|
37
|
-
};
|
|
38
|
-
declare type HeaderObject = {
|
|
39
|
-
name?: string;
|
|
40
|
-
in?: 'query' | 'header' | 'path' | 'cookie';
|
|
41
|
-
description?: string;
|
|
42
|
-
required?: boolean;
|
|
43
|
-
deprecated?: boolean;
|
|
44
|
-
allowEmptyValue?: boolean;
|
|
45
|
-
};
|
|
46
|
-
declare type EncodingObject = {
|
|
47
|
-
contentType?: string;
|
|
48
|
-
headers?: {
|
|
49
|
-
[key: string]: HeaderObject | ReferenceObject;
|
|
50
|
-
};
|
|
51
|
-
style?: string;
|
|
52
|
-
explode?: boolean;
|
|
53
|
-
allowReserved?: boolean;
|
|
54
|
-
};
|
|
55
|
-
export declare type MediaTypeObject = {
|
|
56
|
-
schema?: SchemaObject | ReferenceObject;
|
|
57
|
-
example?: any;
|
|
58
|
-
examples?: {
|
|
59
|
-
[key: string]: ExampleObject | ReferenceObject;
|
|
60
|
-
};
|
|
61
|
-
encoding?: {
|
|
62
|
-
[key: string]: EncodingObject;
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
export declare type ParameterObject = {
|
|
66
|
-
name: string;
|
|
67
|
-
in: 'query' | 'header' | 'path' | 'cookie';
|
|
68
|
-
description?: string;
|
|
69
|
-
required?: boolean;
|
|
70
|
-
deprecated?: boolean;
|
|
71
|
-
allowEmptyValue?: boolean;
|
|
72
|
-
style?: 'form' | 'simple';
|
|
73
|
-
explode?: boolean;
|
|
74
|
-
allowReserved?: boolean;
|
|
75
|
-
schema?: SchemaObject | ReferenceObject;
|
|
76
|
-
example?: any;
|
|
77
|
-
examples?: {
|
|
78
|
-
[key: string]: ExampleObject | ReferenceObject;
|
|
79
|
-
};
|
|
80
|
-
content?: {
|
|
81
|
-
[key: string]: MediaTypeObject;
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
export declare type MediaTypesObject = {
|
|
85
|
-
[key: string]: MediaTypeObject;
|
|
86
|
-
};
|
|
87
|
-
export declare type ServerObject = {
|
|
88
|
-
url: string;
|
|
89
|
-
description?: string;
|
|
90
|
-
variables?: object;
|
|
91
|
-
};
|
|
92
|
-
export declare type RequestBodyObject = {
|
|
93
|
-
description?: string;
|
|
94
|
-
content: {
|
|
95
|
-
[key: string]: MediaTypeObject;
|
|
96
|
-
};
|
|
97
|
-
required?: boolean;
|
|
98
|
-
};
|
|
99
|
-
export declare type LinkObject = {
|
|
100
|
-
operationRef?: string;
|
|
101
|
-
operationId?: string;
|
|
102
|
-
parameters?: {
|
|
103
|
-
[key: string]: any;
|
|
104
|
-
};
|
|
105
|
-
requestBody?: any;
|
|
106
|
-
description?: string;
|
|
107
|
-
server?: ServerObject;
|
|
108
|
-
};
|
|
109
|
-
export declare type LinksObject = {
|
|
110
|
-
[key: string]: LinkObject | ReferenceObject;
|
|
111
|
-
};
|
|
112
|
-
export declare type ResponseObject = {
|
|
113
|
-
description: string;
|
|
114
|
-
headers?: {
|
|
115
|
-
[key: string]: HeaderObject | ReferenceObject;
|
|
116
|
-
};
|
|
117
|
-
content?: MediaTypesObject;
|
|
118
|
-
links?: LinksObject;
|
|
119
|
-
};
|
|
120
|
-
export declare type ResponsesObject = {
|
|
121
|
-
[key: string]: ResponseObject | ReferenceObject;
|
|
122
|
-
};
|
|
123
|
-
export declare type SecurityRequirementObject = {
|
|
124
|
-
[key: string]: string[];
|
|
125
|
-
};
|
|
126
|
-
export declare type OperationObject = {
|
|
127
|
-
tags?: string[];
|
|
128
|
-
summary?: string;
|
|
129
|
-
description?: string;
|
|
130
|
-
externalDocs?: ExternalDocumentationObject;
|
|
131
|
-
operationId?: string;
|
|
132
|
-
parameters?: Array<ParameterObject | ReferenceObject>;
|
|
133
|
-
requestBody?: RequestBodyObject | ReferenceObject;
|
|
134
|
-
responses?: ResponsesObject;
|
|
135
|
-
callbacks?: CallbacksObject;
|
|
136
|
-
deprecated?: boolean;
|
|
137
|
-
security?: SecurityRequirementObject[];
|
|
138
|
-
servers?: ServerObject[];
|
|
139
|
-
};
|
|
140
|
-
export declare type PathItemObject = {
|
|
141
|
-
$ref?: string;
|
|
142
|
-
summary?: string;
|
|
143
|
-
description: string;
|
|
144
|
-
get: OperationObject;
|
|
145
|
-
put: OperationObject;
|
|
146
|
-
post: OperationObject;
|
|
147
|
-
delete: OperationObject;
|
|
148
|
-
options: OperationObject;
|
|
149
|
-
head: OperationObject;
|
|
150
|
-
patch: OperationObject;
|
|
151
|
-
trace: OperationObject;
|
|
152
|
-
servers?: ServerObject[];
|
|
153
|
-
parameters?: [ParameterObject | ReferenceObject];
|
|
154
|
-
};
|
|
155
|
-
declare type PathsObject = {
|
|
156
|
-
[key: string]: PathItemObject;
|
|
157
|
-
};
|
|
158
|
-
export declare type CallbackObject = {
|
|
159
|
-
[key: string]: PathItemObject;
|
|
160
|
-
};
|
|
161
|
-
export declare type CallbacksObject = {
|
|
162
|
-
[key: string]: CallbackObject | ReferenceObject;
|
|
163
|
-
};
|
|
164
|
-
declare type OAuthFlowObject = {
|
|
165
|
-
authorizationUrl?: string;
|
|
166
|
-
tokenUrl?: string;
|
|
167
|
-
refreshUrl?: string;
|
|
168
|
-
scopes?: {
|
|
169
|
-
[key: string]: string;
|
|
170
|
-
};
|
|
171
|
-
};
|
|
172
|
-
declare type OAuthFlowsObject = {
|
|
173
|
-
implicit?: OAuthFlowObject;
|
|
174
|
-
password?: OAuthFlowObject;
|
|
175
|
-
clientCredentials?: OAuthFlowObject;
|
|
176
|
-
authorizationCode?: OAuthFlowObject;
|
|
177
|
-
};
|
|
178
|
-
export declare type SecuritySchemeObject = {
|
|
179
|
-
type: 'apiKey' | 'http' | 'oauth2' | 'openIdConnect';
|
|
180
|
-
description?: string;
|
|
181
|
-
name?: string;
|
|
182
|
-
in?: string;
|
|
183
|
-
scheme?: string;
|
|
184
|
-
bearerFormat?: string;
|
|
185
|
-
flows?: OAuthFlowsObject;
|
|
186
|
-
openIdConnectUrl?: string;
|
|
187
|
-
};
|
|
188
|
-
export declare type SecuritySchemesObject = {
|
|
189
|
-
[key: string]: SecuritySchemeObject | ReferenceObject;
|
|
190
|
-
};
|
|
191
|
-
declare type ComponentsObject = {
|
|
192
|
-
schemas?: {
|
|
193
|
-
[key: string]: SchemaObject | ReferenceObject;
|
|
194
|
-
};
|
|
195
|
-
responses?: ResponsesObject;
|
|
196
|
-
parameters?: {
|
|
197
|
-
[key: string]: ParameterObject | ReferenceObject;
|
|
198
|
-
};
|
|
199
|
-
examples?: {
|
|
200
|
-
[key: string]: ExampleObject | ReferenceObject;
|
|
201
|
-
};
|
|
202
|
-
requestBodies?: {
|
|
203
|
-
[key: string]: RequestBodyObject | ReferenceObject;
|
|
204
|
-
};
|
|
205
|
-
headers?: {
|
|
206
|
-
[key: string]: HeaderObject | ReferenceObject;
|
|
207
|
-
};
|
|
208
|
-
securitySchemes?: SecuritySchemesObject;
|
|
209
|
-
links?: LinksObject;
|
|
210
|
-
callbacks?: {
|
|
211
|
-
[key: string]: CallbackObject | ReferenceObject;
|
|
212
|
-
};
|
|
213
|
-
};
|
|
214
|
-
declare type TagObject = {
|
|
215
|
-
name: string;
|
|
216
|
-
description?: string;
|
|
217
|
-
externalDocs?: ExternalDocumentationObject;
|
|
218
|
-
};
|
|
219
|
-
export declare type Oas3 = {
|
|
220
|
-
openapi: string;
|
|
221
|
-
info: {
|
|
222
|
-
title: string;
|
|
223
|
-
description?: string;
|
|
224
|
-
termsOfService?: string;
|
|
225
|
-
contact?: {
|
|
226
|
-
name?: string;
|
|
227
|
-
url?: string;
|
|
228
|
-
email?: string;
|
|
229
|
-
};
|
|
230
|
-
license?: {
|
|
231
|
-
name: string;
|
|
232
|
-
url?: string;
|
|
233
|
-
};
|
|
234
|
-
version: string;
|
|
235
|
-
};
|
|
236
|
-
servers?: ServerObject[];
|
|
237
|
-
paths: PathsObject;
|
|
238
|
-
components?: ComponentsObject;
|
|
239
|
-
security?: SecurityRequirementObject[];
|
|
240
|
-
tags?: TagObject[];
|
|
241
|
-
externalDocs?: ExternalDocumentationObject;
|
|
242
|
-
};
|
|
243
|
-
export {};
|