Skip to content

Commit cb2c06d

Browse files
committed
Add GraphQL typing
Signed-off-by: Alan Cha <[email protected]>
1 parent bd7a921 commit cb2c06d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3162
-2345
lines changed

packages/openapi-to-graphql/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Schema options:
170170

171171
Resolver options:
172172

173-
- `headers` (type: `object` | `function`, default: `{}`): Headers to be sent in every request to the API described by the given OAS. Parameters defined in the OpenAPI Specification to set these headers will be ignored by OpenAPI-to-GraphQL. If used as a function, the following parameters will be exposed per-request: `req` (the GraphQL resolver's context.request object), `method`, `path`, and `title`.
173+
- `headers` (type: `object` | `function`, default: `{}`): Headers to be sent in every request to the API described by the given OAS. Parameters defined in the OpenAPI Specification to set these headers will be ignored by OpenAPI-to-GraphQL. If used as a function, the following parameters will be exposed per-request: `req` (the GraphQL resolver's `context.request` object), the operation's `method`, the operation's `path`, and the API `title`.
174174

175175
- `qs` (type: `object`, default: `{}`): Query parameters to be sent in every request to the API described by the given OAS. Parameters defined in the OpenAPI Specification to set these query parameters will be ignored by OpenAPI-to-GraphQL.
176176

packages/openapi-to-graphql/lib/auth_builder.d.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
* Functions to create viewers that allow users to pass credentials to resolve
33
* functions used by OpenAPI-to-GraphQL.
44
*/
5-
import { GraphQLObjectType as GQObjectType } from 'graphql';
6-
import { Args, ResolveFunction, GraphQLOperationType } from './types/graphql';
5+
import { GraphQLObjectType, GraphQLFieldResolver } from 'graphql';
6+
import { Args, GraphQLOperationType } from './types/graphql';
77
import { PreprocessingData } from './types/preprocessing_data';
8-
declare type Viewer = {
9-
type: GQObjectType;
10-
resolve: ResolveFunction;
8+
declare type Viewer<TSource, TContext, TArgs> = {
9+
type: GraphQLObjectType;
10+
resolve: GraphQLFieldResolver<TSource, TContext, TArgs>;
1111
args: Args;
1212
description: string;
1313
};
@@ -17,7 +17,7 @@ declare type Viewer = {
1717
* i.e. inside either rootQueryFields/rootMutationFields or inside
1818
* rootQueryFields/rootMutationFields for further processing
1919
*/
20-
export declare function createAndLoadViewer(queryFields: object, operationType: GraphQLOperationType, data: PreprocessingData): {
21-
[key: string]: Viewer;
20+
export declare function createAndLoadViewer<TSource, TContext, TArgs>(queryFields: object, operationType: GraphQLOperationType, data: PreprocessingData<TSource, TContext, TArgs>): {
21+
[key: string]: Viewer<TSource, TContext, TArgs>;
2222
};
2323
export {};

packages/openapi-to-graphql/lib/auth_builder.js

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql/lib/auth_builder.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Utilities related to GraphQL.
33
*/
4-
import { GraphQLObjectType as GQObjectType } from 'graphql';
4+
import { GraphQLObjectType } from 'graphql';
55
/**
66
* Returns empty GraphQLObjectType.
77
*/
8-
export declare function getEmptyObjectType(name: string): GQObjectType;
8+
export declare function getEmptyObjectType(name: string): GraphQLObjectType;

packages/openapi-to-graphql/lib/graphql_tools.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql/lib/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ declare type Result = {
3535
/**
3636
* Creates a GraphQL interface from the given OpenAPI Specification (2 or 3).
3737
*/
38-
export declare function createGraphQLSchema(spec: Oas3 | Oas2 | (Oas3 | Oas2)[], options?: Options): Promise<Result>;
38+
export declare function createGraphQLSchema<TSource, TContext, TArgs>(spec: Oas3 | Oas2 | (Oas3 | Oas2)[], options?: Options<TSource, TContext, TArgs>): Promise<Result>;
3939
export { sanitize, CaseStyle } from './oas_3_tools';
4040
export { GraphQLOperationType } from './types/graphql';

packages/openapi-to-graphql/lib/index.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)