Following the Relay Modern documentation, first I started off by using the buildSchema()
function and placing my schema and rootValue in JavaScript file and use it whenever needed.
Later I found out that relay-compiler
needs a schema file either in JSON or .graphql
format; So I copied my schema in schema.graphql
and everything works as expected.
To avoid maintaining my schema in two places I can read the schema.graphql
file and pass it to the buildSchema()
function and it should work, but I was wondering if that's the correct approach or if there are better ways of doing it? Is there any way to avoid using buildSchema()
function at all and totally rely on schema.graphql
solely?