From 5009ea66ebad9963bab8ec782a3b1adb691e3add Mon Sep 17 00:00:00 2001 From: Chris Filipowski Date: Mon, 12 Mar 2018 23:11:38 +0800 Subject: [PATCH 1/2] Add typings for graphql-list-fields --- .../graphql-list-fields-tests.ts | 42 +++++++++++++++++++ types/graphql-list-fields/index.d.ts | 12 ++++++ types/graphql-list-fields/tsconfig.json | 23 ++++++++++ types/graphql-list-fields/tslint.json | 1 + 4 files changed, 78 insertions(+) create mode 100644 types/graphql-list-fields/graphql-list-fields-tests.ts create mode 100644 types/graphql-list-fields/index.d.ts create mode 100644 types/graphql-list-fields/tsconfig.json create mode 100644 types/graphql-list-fields/tslint.json diff --git a/types/graphql-list-fields/graphql-list-fields-tests.ts b/types/graphql-list-fields/graphql-list-fields-tests.ts new file mode 100644 index 0000000000..7624a3cbd8 --- /dev/null +++ b/types/graphql-list-fields/graphql-list-fields-tests.ts @@ -0,0 +1,42 @@ +import getFieldNames = require("graphql-list-fields"); + +import { + GraphQLID, + GraphQLInterfaceType, + GraphQLObjectType, + GraphQLResolveInfo, + GraphQLSchema, + GraphQLString +} from "graphql"; + +const sampleGraphQLResolveInfo: GraphQLResolveInfo = { + fieldName: "", + fieldNodes: [], + returnType: GraphQLString, + parentType: new GraphQLInterfaceType({ + name: "Sample", + fields: { + name: { type: GraphQLString } + } + }), + path: undefined, + schema: new GraphQLSchema({ + query: new GraphQLObjectType({ + name: "SampleType", + fields: {} + }) + }), + fragments: {}, + rootValue: null, + operation: { + kind: "OperationDefinition", + operation: "query", + selectionSet: { + kind: "SelectionSet", + selections: [] + } + }, + variableValues: {} +}; + +const fieldNames: string[] = getFieldNames(sampleGraphQLResolveInfo); diff --git a/types/graphql-list-fields/index.d.ts b/types/graphql-list-fields/index.d.ts new file mode 100644 index 0000000000..1cd4a1c005 --- /dev/null +++ b/types/graphql-list-fields/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for graphql-list-fields 2.0 +// Project: https://github.com/jakepusateri/graphql-list-fields#readme +// Definitions by: Chris Filipowski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { GraphQLResolveInfo } from "graphql"; + +declare namespace getFieldList {} +declare function getFieldList(info: GraphQLResolveInfo): string[]; + +export = getFieldList; diff --git a/types/graphql-list-fields/tsconfig.json b/types/graphql-list-fields/tsconfig.json new file mode 100644 index 0000000000..6f53c2c900 --- /dev/null +++ b/types/graphql-list-fields/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "graphql-list-fields-tests.ts" + ] +} diff --git a/types/graphql-list-fields/tslint.json b/types/graphql-list-fields/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/graphql-list-fields/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 09b206f5f7a67630d457c569927010a162bb5d5f Mon Sep 17 00:00:00 2001 From: Chris Filipowski Date: Wed, 14 Mar 2018 20:30:59 +0800 Subject: [PATCH 2/2] graphql-list-fields: remove empty namespace (discouraged practice) --- types/graphql-list-fields/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/graphql-list-fields/index.d.ts b/types/graphql-list-fields/index.d.ts index 1cd4a1c005..362658deb9 100644 --- a/types/graphql-list-fields/index.d.ts +++ b/types/graphql-list-fields/index.d.ts @@ -6,7 +6,6 @@ import { GraphQLResolveInfo } from "graphql"; -declare namespace getFieldList {} declare function getFieldList(info: GraphQLResolveInfo): string[]; export = getFieldList;