0

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?

RomanHotsiy
  • 4,978
  • 1
  • 25
  • 36
Mahdi
  • 9,247
  • 9
  • 53
  • 74

1 Answers1

1

This is the correct and required approach.
You can't avoid using the buildSchema function with your .graphql file ; but you could construct the full schema in JavaScript - see bottom of this page.

I recommend sticking with the Schema Language notation though.

yachaka
  • 5,429
  • 1
  • 23
  • 35