问题描述
当使用带有以下 schema.json 的 graphql-tools JsonFileLoader 时:
opel
我收到以下错误:
{
"UserObjectType": {
"id": "Int","username": "String","firstName": "String","lastName": "String","avatar": "AvatarObjectType","dateCreated": "DateTime","notificationPreferences": "GenericScalar"
},"AvatarObjectType": { "id": "Int","avatarUrl": "String" },"scalar": ["DateTime","GenericScalar"],"Query": {
"GetCurrentUser": "UserObjectType"
}
}
这是我的代码:
Unable to find any GraphQL type definitions for the following pointers:
- UserObjectType,- AvatarObjectType,- scalar,- Query
at prepareResult (dist/load/src/load-typedefs.js:70:15)
at loadTypedefs (dist/load/src/load-typedefs.js:35:12)
Reproduction repo 是 here,更具体地说,我使用 JSONFileLoader 的测试是 here。
编辑:我使用 const JSONSchema = await loadSchema(schema,{
loaders: [new JsonFileLoader()],});
const mocks = {
String: () => "abc",Int: () => 56,UserObjectType: () => ({
firstName: "John",lastName: "Smith",}),};
// Create a new schema with mocks
const schemaWithMocks = addMocksToSchema({
schema: JSONSchema,mocks,});
的自省插件生成了一个新的 JSON,您可以找到 here.
将其加载到我的测试中时,出现类似错误:
@graphql-codegen/cli
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)