Koa-GraphQL : Removed default export and bumped GraphQL to v 15.1.0 (#45443)

* Updated GraphQL dependency to v15
Changed types so it does not use default export

* Fixes after lint run
This commit is contained in:
Martin Seidel 2020-06-13 19:46:38 +02:00 committed by GitHub
parent 72c9bd8331
commit 60edc0e069
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 66 deletions

View File

@ -5,79 +5,75 @@
// TypeScript Version: 3.0
/// <reference types="node" />
import { Context, Request, Response, Middleware } from "koa";
import {
GraphQLError,
GraphQLSchema,
GraphQLFieldResolver,
ValidationContext,
ASTVisitor
} from "graphql";
import { GraphQLParams, RequestInfo } from "express-graphql";
import { Context, Request, Response, Middleware } from 'koa';
import { GraphQLError, GraphQLSchema, GraphQLFieldResolver, ValidationContext, ASTVisitor } from 'graphql';
import { RequestInfo } from 'express-graphql';
export type Options =
| ((request: Request, repsonse: Response, ctx: Context) => OptionsResult)
| OptionsResult;
export = graphqlHTTP;
export type OptionsResult = OptionsData | Promise<OptionsData>;
declare function graphqlHTTP(options: graphqlHTTP.Options): Middleware;
export interface OptionsData {
/**
* A GraphQL schema from graphql-js.
*/
schema: GraphQLSchema;
declare namespace graphqlHTTP {
type Options = ((request: Request, response: Response, ctx: Context) => OptionsResult) | OptionsResult;
/**
* A value to pass as the context to this middleware.
*/
context?: any;
type OptionsResult = OptionsData | Promise<OptionsData>;
/**
* An object to pass as the rootvalue to the graphql() function.
*/
rootValue?: any;
interface OptionsData {
/**
* A GraphQL schema from graphql-js.
*/
schema: GraphQLSchema;
/**
* A boolean to configure whether the output should be pretty-printed.
*/
pretty?: boolean;
/**
* A value to pass as the context to this middleware.
*/
context?: any;
/**
* An optional function which will be used to format any errors produced by
* fulfilling a GraphQL operation. If no function is provided, GraphQL's
* default spec-compliant `formatError` function will be used.
*/
formatError?: (error: GraphQLError, context?: any) => any;
/**
* An object to pass as the rootvalue to the graphql() function.
*/
rootValue?: any;
/**
* An optional array of validation rules that will be applied on the document
* in addition to those defined by the GraphQL spec.
*/
validationRules?: Array<(arg0: ValidationContext) => ASTVisitor>;
/**
* A boolean to configure whether the output should be pretty-printed.
*/
pretty?: boolean;
/**
* An optional function for adding additional metadata to the GraphQL response
* as a key-value object. The result will be added to "extensions" field in
* the resulting JSON. This is often a useful place to add development time
* info such as the runtime of a query or the amount of resources consumed.
*
* Information about the request is provided to be used.
*
* This function may be async.
*/
extensions?: (info: RequestInfo) => { [key: string]: any };
/**
* An optional function which will be used to format any errors produced by
* fulfilling a GraphQL operation. If no function is provided, GraphQL's
* default spec-compliant `formatError` function will be used.
*/
formatError?: (error: GraphQLError, context?: any) => any;
/**
* A boolean to optionally enable GraphiQL mode.
*/
graphiql?: boolean;
/**
* An optional array of validation rules that will be applied on the document
* in addition to those defined by the GraphQL spec.
*/
validationRules?: Array<(arg0: ValidationContext) => ASTVisitor>;
/**
* A resolver function to use when one is not provided by the schema.
* If not provided, the default field resolver is used (which looks for a
* value or method on the source value with the field's name).
*/
fieldResolver?: GraphQLFieldResolver<any, any>;
/**
* An optional function for adding additional metadata to the GraphQL response
* as a key-value object. The result will be added to "extensions" field in
* the resulting JSON. This is often a useful place to add development time
* info such as the runtime of a query or the amount of resources consumed.
*
* Information about the request is provided to be used.
*
* This function may be async.
*/
extensions?: (info: RequestInfo) => { [key: string]: any };
/**
* A boolean to optionally enable GraphiQL mode.
*/
graphiql?: boolean;
/**
* A resolver function to use when one is not provided by the schema.
* If not provided, the default field resolver is used (which looks for a
* value or method on the source value with the field's name).
*/
fieldResolver?: GraphQLFieldResolver<any, any>;
}
}
export default function graphqlHTTP(options: Options): Middleware;

View File

@ -1,6 +1,6 @@
import * as Koa from 'koa';
import * as mount from 'koa-mount';
import graphqlHTTP from 'koa-graphql';
import * as graphqlHTTP from 'koa-graphql';
import { buildSchema } from 'graphql';
const schema = buildSchema(`type Query { hello: String }`);

View File

@ -1,7 +1,7 @@
{
"private": true,
"dependencies": {
"graphql": "^14.5.3",
"graphql": "^15.1.0",
"express-graphql": "^0.9.0"
}
}