2017-08-24 78 views
2

我想獲得graphql的類型定義。我已經安裝了graphql@types/graphql,並在我的文件中有​​。但是,我無法訪問諸如GraphQLSchemaConfig之類的類型。我如何訪問這些?類型定義似乎正確加載,因爲構造函數要求提供該類型的參數。DefinitelyTyped爲graphql

回答

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