Merge pull request #24236 from filipows/master

Add typings for graphql-list-fields
This commit is contained in:
Arthur Ozga
2018-03-15 12:47:37 -07:00
committed by GitHub
4 changed files with 77 additions and 0 deletions

View File

@@ -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);

11
types/graphql-list-fields/index.d.ts vendored Normal file
View File

@@ -0,0 +1,11 @@
// Type definitions for graphql-list-fields 2.0
// Project: https://github.com/jakepusateri/graphql-list-fields#readme
// Definitions by: Chris Filipowski <https://github.com/filipows>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import { GraphQLResolveInfo } from "graphql";
declare function getFieldList(info: GraphQLResolveInfo): string[];
export = getFieldList;

View File

@@ -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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }