From 5a17a5ea7cec498236801533f90529fdcdced362 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Tue, 27 Aug 2019 03:48:05 +0300 Subject: [PATCH] Remove `@types/express-graphql` (#37883) --- notNeededPackages.json | 6 + .../express-graphql/express-graphql-tests.ts | 47 ----- types/express-graphql/index.d.ts | 163 ------------------ types/express-graphql/package.json | 6 - types/express-graphql/tsconfig.json | 25 --- types/express-graphql/tslint.json | 6 - types/koa-graphql/index.d.ts | 2 +- types/koa-graphql/package.json | 3 +- 8 files changed, 9 insertions(+), 249 deletions(-) delete mode 100644 types/express-graphql/express-graphql-tests.ts delete mode 100644 types/express-graphql/index.d.ts delete mode 100644 types/express-graphql/package.json delete mode 100644 types/express-graphql/tsconfig.json delete mode 100644 types/express-graphql/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index aa14641b76..9737f27fed 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -948,6 +948,12 @@ "sourceRepoURL": "https://github.com/silentmatt/expr-eval", "asOfVersion": "1.1.0" }, + { + "libraryName": "express-graphql", + "typingsPackageName": "express-graphql", + "sourceRepoURL": "https://github.com/graphql/express-graphql", + "asOfVersion": "0.9.0" + }, { "libraryName": "express-validator", "typingsPackageName": "express-validator", diff --git a/types/express-graphql/express-graphql-tests.ts b/types/express-graphql/express-graphql-tests.ts deleted file mode 100644 index 2b4df04379..0000000000 --- a/types/express-graphql/express-graphql-tests.ts +++ /dev/null @@ -1,47 +0,0 @@ -import express = require("express"); -import "express-session"; -import graphqlHTTP = require("express-graphql"); -import { buildSchema } from "graphql"; - -const app = express(); -const schema = buildSchema(`type Query { hello: String }`); - -const validationRules = [ - () => ({ Field: () => false }), - () => ({ Variable: () => true }), -]; - -const graphqlOption: graphqlHTTP.OptionsData = { - graphiql: true, - schema, - customFormatErrorFn: (error: Error) => ({ - message: error.message, - }), - validationRules, - extensions: ({ document, variables, operationName, result }) => ({ key: "value", key2: "value" }), -}; - -const graphqlOptionRequest = (request: express.Request): graphqlHTTP.OptionsData => ({ - graphiql: true, - schema, - context: request.session, - validationRules, -}); - -const graphqlOptionRequestAsync = async (request: express.Request): Promise => { - return { - graphiql: true, - schema: await Promise.resolve(schema), - context: request.session, - extensions: async args => {}, - validationRules, - }; -}; - -app.use("/graphql1", graphqlHTTP(graphqlOption)); - -app.use("/graphql2", graphqlHTTP(graphqlOptionRequest)); - -app.use("/graphqlasync", graphqlHTTP(graphqlOptionRequestAsync)); - -app.listen(8080, () => console.log("GraphQL Server running on localhost:8080")); diff --git a/types/express-graphql/index.d.ts b/types/express-graphql/index.d.ts deleted file mode 100644 index e3bf561eb6..0000000000 --- a/types/express-graphql/index.d.ts +++ /dev/null @@ -1,163 +0,0 @@ -// Type definitions for express-graphql 0.8 -// Project: https://github.com/graphql/express-graphql -// Definitions by: Isman Usoh -// Nitin Tutlani -// Daniel Fader -// Ehsan Ziya -// Margus Lamp -// Firede -// Ivan Goncharov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 - -import { Request, Response } from "express"; -import { - ExecutionArgs, - ExecutionResult, - DocumentNode, - GraphQLSchema, - GraphQLError, - GraphQLFieldResolver, - ValidationContext, - ASTVisitor, -} from "graphql"; -export = graphqlHTTP; - -declare namespace graphqlHTTP { - /** - * Used to configure the graphqlHTTP middleware by providing a schema - * and other configuration options. - * - * Options can be provided as an Object, a Promise for an Object, or a Function - * that returns an Object or a Promise for an Object. - */ - export type Options = - | ((request: Request, response: Response, params?: GraphQLParams) => OptionsResult) - | OptionsResult; - export type OptionsResult = OptionsData | Promise; - export interface OptionsData { - /** - * A GraphQL schema from graphql-js. - */ - schema: GraphQLSchema; - - /** - * A value to pass as the context to the graphql() function. - */ - context?: any; - - /** - * An object to pass as the rootValue to the graphql() function. - */ - rootValue?: any; - - /** - * A boolean to configure whether the output should be pretty-printed. - */ - pretty?: boolean | null; - - /** - * An optional array of validation rules that will be applied on the document - * in additional to those defined by the GraphQL spec. - */ - validationRules?: Array<(ctx: ValidationContext) => ASTVisitor> | null; - - /** - * An optional function which will be used to validate instead of default `validate` - * from `graphql-js`. - */ - customValidateFn?: (( - schema: GraphQLSchema, - documentAST: DocumentNode, - rules: ReadonlyArray, - ) => ReadonlyArray) | null; - - /** - * An optional function which will be used to execute instead of default `execute` - * from `graphql-js`. - */ - customExecuteFn?: ((args: ExecutionArgs) => Promise) | null; - - /** - * 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. - */ - customFormatErrorFn?: ((error: GraphQLError) => any) | null; - - /** - * `formatError` is deprecated and replaced by `customFormatErrorFn`. It will - * be removed in version 1.0.0. - */ - formatError?: ((error: GraphQLError) => any) | null; - - /** - * 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 }) | null; - - /** - * A boolean to optionally enable GraphiQL mode. - */ - graphiql?: boolean | null; - - /** - * 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 | null; - } - - /** - * All information about a GraphQL request. - */ - export interface RequestInfo { - /** - * The parsed GraphQL document. - */ - document: DocumentNode | null | undefined; - - /** - * The variable values used at runtime. - */ - variables: { [name: string]: any } | null | undefined; - - /** - * The (optional) operation name requested. - */ - operationName: string | null | undefined; - - /** - * The result of executing the operation. - */ - result: any; - - /** - * A value to pass as the context to the graphql() function. - */ - context?: any; - } - - export interface GraphQLParams { - query: string | null | undefined; - variables: { [name: string]: any } | null | undefined; - operationName: string | null | undefined; - raw: boolean | null | undefined; - } - - type Middleware = (request: Request, response: Response) => Promise; -} - -/** - * Middleware for express; takes an options object or function as input to - * configure behavior, and returns an express middleware. - */ -declare function graphqlHTTP(options: graphqlHTTP.Options): graphqlHTTP.Middleware; diff --git a/types/express-graphql/package.json b/types/express-graphql/package.json deleted file mode 100644 index 1e9e930126..0000000000 --- a/types/express-graphql/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "private": true, - "dependencies": { - "graphql": "^14.5.3" - } -} diff --git a/types/express-graphql/tsconfig.json b/types/express-graphql/tsconfig.json deleted file mode 100644 index ac6ad5f138..0000000000 --- a/types/express-graphql/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es2015", - "lib": [ - "es6", - "esnext.asynciterable" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "express-graphql-tests.ts" - ] -} \ No newline at end of file diff --git a/types/express-graphql/tslint.json b/types/express-graphql/tslint.json deleted file mode 100644 index 4c4fc86ace..0000000000 --- a/types/express-graphql/tslint.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "strict-export-declare-modifiers": false - } -} diff --git a/types/koa-graphql/index.d.ts b/types/koa-graphql/index.d.ts index a6bbb5fc13..31da156747 100644 --- a/types/koa-graphql/index.d.ts +++ b/types/koa-graphql/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/chentsulin/koa-graphql // Definitions by: Matheus Gonçalves da Silva // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 3.0 /// import { Context, Request, Response, Middleware } from "koa"; diff --git a/types/koa-graphql/package.json b/types/koa-graphql/package.json index 1e9e930126..17af68a59c 100644 --- a/types/koa-graphql/package.json +++ b/types/koa-graphql/package.json @@ -1,6 +1,7 @@ { "private": true, "dependencies": { - "graphql": "^14.5.3" + "graphql": "^14.5.3", + "express-graphql": "^0.9.0" } }