Search code examples
relayjsrelay

Integrating RelayJS and Azure table storage


The documentation on RelayJS says the RelayJS can use node.js as a GraphQL server, but not ASP.NET web service.

How can I use RelayJS with ASP.NET web api end point?


Solution

  • How can I use RelayJS with ASP.NET web api end point?

    TL;DR;

    By placing a GraphQL server in-between Relay client-side and ASP.NET web api end point.


    The Getting Started page of Relay documentation clearly mentions that 2 additional things are needed to use Relay:

    1. A GraphQL Schema: This is your data model. You need to map your ASP.NET web API to a GraphQL schema.
    2. A GraphQL Server: Your client-side speaks to this server. In your case, this GraphQL server will talk to your ASP.NET web API.

    A good example of this is GraphQL schema and server wrapping Star Wars API.


    Some conecptual clarifications about your question

    1. Relay is a specification. It's actually called GraphQL Relay Specification. It's not restricted to JavaScript. Check Awesome Relay to find the list of languages for which Relay libraries are already available.
    2. It helps to think of Relay and GraphQL as 2 sides:
      • server-side consisting of GraphQL server, which speaks the schema. It can receive queries and mutation requests. How you prepare and provide the requested data depend on back-end logic. For example, you may have your own database, which you use directly to fetch / prepare the exposed data. Or you may use an external API to fetch / prepare data. There are libraries in languages other than JavaScript to help you write GraphQL schema and server. Check Awesome GraphQL.
      • client-side using Relay library, which talks to a GraphQL server and fetches data as needed.