【问题标题】:DefinitelyTyped for graphql绝对类型为 graphql
【发布时间】:2018-02-02 20:12:26
【问题描述】:
我正在尝试获取 graphql 的类型定义。我已经安装了graphql 和@types/graphql,在我的文件中我有import * as graphql from "graphql"。但是,我无法访问诸如GraphQLSchemaConfig 之类的类型。我如何访问这些?类型定义似乎正在正确加载,因为构造函数要求输入该类型的参数。
【问题讨论】:
标签:
typescript
graphql
definitelytyped
【解决方案1】:
GraphQLSchemaConfig 在type/schema.d.ts 文件中定义和导出。但是,index.d.ts 文件仅重新导出 GraphQLSchema。我们可以通过这样做来解决这个问题...
import { GraphQLSchemaConfig } from "graphql/type/schema";
definitely typed repository graphql directory.有详细介绍
-
index.d.ts 包含 export * from './type';
-
type/index.d.ts 包含 export { GraphQLSchema } from './schema';
-
type/schema.d.ts 包含 export interface GraphQLSchemaConfig { /* ... */ )
这是我们需要引用的最后一个文件才能导入GraphQLSchemaConfig。