I want to build a web app with Javascript for the front end and C# for the back end and I want to determine the value of GraphQL.
- For my C# back end I use a GraphQL implementation named GraphQL for .NET.
- For my front end, I would like to use Relay as it plays well with ReactJS.
Now for my back end, I implemented a sample schema like in one of the examples which looks like this:
public class StarWarsSchema : Schema
{
public StarWarsSchema()
{
Query = new StarWarsQuery();
}
}
In my front end, I now need to tell Relay somehow about this schema. At least this is what I understood when walking through the tutorials, because for some reason the GraphQL queries needs to be transpiled. This is an example as how I would like to load all Droids:
class Content extends React.Component<ContentProps, { }> {
...
}
export default Relay.createContainer(Content, {
fragments: {
viewer: () => Relay.QL`
fragment on User {
query HeroNameQuery {
droids {
id
name
}
}
}
`,
}
});
In one of the examples for Relay, I have seen that the babel-relay-plugin is used for conversion. It gets a schema file (JSON). The Getting Started Guide of Relay shows, how to create such a schema with graphql-js and graphql-relay-js.
Now my questions:
- Do I really need to create schemas on the front and on the back end?
- What is the point of teaching Relay my schema, as the back end already uses the schema to return the well formed data?
- What is the benefit at all from using Relay in this scenario? What would I lose when I would just access the backend via a regular REST endpoint along with a GraphQL query as a parameter?