How to update graphql endpoint (not using Graph.cool)

294 Views Asked by At

I spent some time working through the ReactQL starter kit and watched the intro video outlining how the kit is set up, but one area I am still confused on is where to put our graphql specific stuff if we don't use a Graph.cool endpoint.

Graph.cool seems great, but to get more experience with Graphql, I want to set up my own schema, queries, etc.

What is the best practice for handling our own graphql stuff? Do I place the:

app.get('/', {
graphiql: true
})

or Koa equivalent in the config/project.js APOLLO variable? I am more familiar with Express than Koa, but could also see it going in the entry/server.js file.

1

There are 1 best solutions below

2
On

The GraphQL endpoint is set in config/project.js, under the APOLLO variable by default:

export const APOLLO = {
  uri: 'https://api.graph.cool/simple/v1/cinomw2r1018601o42x5z69uc',
};

Change APOLLO.uri to point to another GraphQL server will update both the server and browser environments to use that new server.

If you want to create your own GraphQL server alongside the front-end web server that ReactQL starts by default, there's an example you can see here for wiring up your own schema and GraphQL endpoint:

https://github.com/reactql/examples/tree/master/graphql-server

(Usage instructions for example projects can be found here)