我正在使用中继编译器,它不允许我编译具有实现多个接口的类型的模式。我做了一个小测试项目:
包.json
{
"scripts": {
"relay": "relay-compiler --src ./ --schema schema.graphqls"
},
"dependencies": {
"react-relay": "1.5.0"
},
"devDependencies": {
"relay-compiler": "1.5.0"
}
}
架构.graphqls
interface First {
a: String
}
interface Second {
b: String
}
type Something implements First, Second {
a: String
b: String
}
测试.js
import { graphql } from "react-relay";
graphql`fragment Test_item on Something {
a
b
}`;
如果你用 npm run relay 运行它(在 npm install 之后)你会得到错误:
Error: Error loading schema. Expected the schema to be a .graphql or a .json
file, describing your GraphQL server's API. Error detail:
GraphQLError: Syntax Error: Unexpected Name "Second"
任何想法为什么会发生这种情况?