DefinitelyTyped 用于 graphql

DefinitelyTyped for graphql

我正在尝试获取 graphql 的类型定义。我已经安装了 graphql@types/graphql,并且在我的文件中有 import * as graphql from "graphql"。但是,我无法访问 GraphQLSchemaConfig 等类型。我如何访问这些?类型定义似乎加载正确,因为构造函数要求该类型的参数。

GraphQLSchemaConfigtype/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