Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to customize graphql schema with OAS extensions #379

Closed
wants to merge 12 commits into from
2 changes: 1 addition & 1 deletion packages/openapi-to-graphql/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ declare type Result<TSource, TContext, TArgs> = {
* Creates a GraphQL interface from the given OpenAPI Specification (2 or 3).
*/
export declare function createGraphQLSchema<TSource, TContext, TArgs>(spec: Oas3 | Oas2 | (Oas3 | Oas2)[], options?: Options<TSource, TContext, TArgs>): Promise<Result<TSource, TContext, TArgs>>;
export { sanitize, CaseStyle } from './oas_3_tools';
export { CaseStyle, sanitize } from './oas_3_tools';
export { GraphQLOperationType } from './types/graphql';
31 changes: 24 additions & 7 deletions packages/openapi-to-graphql/lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/openapi-to-graphql/lib/index.js.map

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion packages/openapi-to-graphql/lib/oas_3_tools.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Oas3, ServerObject, ParameterObject, SchemaObject, OperationObject, Res
import { PreprocessingData, ProcessedSecurityScheme } from './types/preprocessing_data';
import { InternalOptions } from './types/options';
export declare type SchemaNames = {
fromExtension?: string;
fromRef?: string;
fromSchema?: string;
fromPath?: string;
Expand Down Expand Up @@ -38,6 +39,11 @@ export declare enum HTTP_METHODS {
'head' = "head"
}
export declare const SUCCESS_STATUS_RX: RegExp;
export declare enum OAS_GRAPHQL_EXTENSIONS {
TypeName = "x-graphql-type-name",
FieldName = "x-graphql-field-name",
EnumMapping = "x-graphql-enum-mapping"
}
/**
* Given an HTTP method, convert it to the HTTP_METHODS enum
*/
Expand Down Expand Up @@ -70,7 +76,7 @@ export declare function countOperationsWithPayload(oas: Oas3): number;
/**
* Resolves the given reference in the given object.
*/
export declare function resolveRef(ref: string, oas: Oas3): any;
export declare function resolveRef<T = any>(ref: string, oas: Oas3): T;
/**
* Returns the base URL to use for the given operation.
*/
Expand Down
18 changes: 13 additions & 5 deletions packages/openapi-to-graphql/lib/oas_3_tools.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/openapi-to-graphql/lib/oas_3_tools.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/openapi-to-graphql/lib/preprocessor.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Oas3, LinkObject, SchemaObject } from './types/oas3';
import { Oas3, LinkObject, ReferenceObject, SchemaObject } from './types/oas3';
import { InternalOptions } from './types/options';
import { DataDefinition } from './types/operation';
import { PreprocessingData } from './types/preprocessing_data';
Expand All @@ -12,6 +12,6 @@ export declare function preprocessOas<TSource, TContext, TArgs>(oass: Oas3[], op
* Method to either create a new or reuse an existing, centrally stored data
* definition.
*/
export declare function createDataDef<TSource, TContext, TArgs>(names: Oas3Tools.SchemaNames, schema: SchemaObject, isInputObjectType: boolean, data: PreprocessingData<TSource, TContext, TArgs>, oas: Oas3, links?: {
export declare function createDataDef<TSource, TContext, TArgs>(names: Oas3Tools.SchemaNames, schema: SchemaObject | ReferenceObject, isInputObjectType: boolean, data: PreprocessingData<TSource, TContext, TArgs>, oas: Oas3, links?: {
[key: string]: LinkObject;
}): DataDefinition;