facebook/relay

How to multiple schema.json

spyalert01 opened this issue · 7 comments

If we are building a bigger application where we have several module, we may be defining a few schema, and hence has multiple schema.json files.

How can we make sure all these schemas are properly loaded?

Can you elaborate more on why you need multiple schemas? GraphQL is designed to support multiple backends within the same schema. Unfortunately, Relay currently does not support multiple schemas in one application. However, it maybe possible in the future as we support data from multiple sources (see #114)

When dealing with bigger application, we may need to group schema based on module requirement, the schema.js file may be big and messy when handle bigger application if we can't group it.

it will make thing hard to maintain as well.

Just like when we are doing MVC, we can have many M.

It's natural to split your schema definition into multiple files. However, you'll still have one file that imports all these type definitions and defines the root and mutation types.

Wouldn't it take too much memory / space, if we keep importing those schema that we don't need at certain point of time?

It won't! You see, from the perspective of the client code, the schema.json is only used to compile Relay.QL; expressions. If you make no mention of one part of your schema in a Relay.QL expression, then no extra bytes will be compiled into your client code.

On the server side, a larger schema will take up more memory on your server, but as compared to other parts of your app, you should be able to let that schema file grow as large as you like without consequences.

We recommend having one schema that describes your entire data universe. Relay will use only the parts of that query it needs to compile client code, and will generate requests to your /graphql endpoint that query only those parts of the schema necessary to resolve data for your running app.

Is React Relay suitable to build medium to large size application using React+Relay?
Example a Mini ERP System or a Retail Chain Management System, that involve End to End process of a business?
I used to do this in PHP.

Relay is in use in Facebook's Groups and Mobile Ads Manager apps, as well as a number of products currently under development. It's working well for us, and we hope that it works just as well for you!

If you have any more questions about using a GraphQL schema with Relay, feel free to reopen this issue, or open a new one on a new topic.