我使用的是中继编译器,它不允许我用实现多个接口的类型编译模式。我做了一个小测试项目:
package.json
{
"scripts": {
"relay": "relay-compiler --src ./ --schema schema.graphqls"
},
"dependencies": {
"react-relay": "1.5.0"
},
"devDependencies": {
"relay-compiler": "1.5.0"
}
}schema.graphqls
interface First {
a: String
}
interface Second {
b: String
}
type Something implements First, Second {
a: String
b: String
}test.js
import { graphql } from "react-relay";
graphql`fragment Test_item on Something {
a
b
}`;如果您使用npm运行继电器(在npm安装之后)运行此操作,则会得到以下错误:
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"知道为什么会这样吗?
发布于 2018-03-27 20:12:22
对于多个接口,您应该使用符号,而不是逗号。见此处:http://facebook.github.io/graphql/draft/#sec-Interfaces
type Something implements First & Secondhttps://stackoverflow.com/questions/49521575
复制相似问题