I am using the relay compiler and it is not letting me compile a schema with a type that implements multiple interfaces. I made a small test project:
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
}`;
If you run this with npm run relay (after npm install) you get the error:
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"
Any ideas why this is happening?
You should use an ampersand instead of a comma for multiple interfaces. See here: http://facebook.github.io/graphql/draft/#sec-Interfaces
type Something implements First & Second
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With