How to run the simple React Todo app without Slash?

I went through these steps to build a basic todo app with Dgraph and React: graphql-sample-apps/todo-app-react at master · dgraph-io/graphql-sample-apps · GitHub

I did all the steps, but when I went to the UI, it prompted me to enter a Slash Graphql endpoint. I expected the app to work without Slash because the tutorial told me to set up Dgraph locally with Docker. And the tutorial says " Also, if you are not running Dgraph locally, be sure to modify graphqlUrl to point at accurate GraphQL endpoint." I couldn’t find the graphqlUrl in the example project (a search turned up blank), but I was running Dgraph locally, so I clicked cancel.

Then in the UI, if I typed a todo in the input field, it gave this error:

Unhandled Rejection (Error): Network error: Unexpected token < in JSON at position 0

To me it looks like there’s a disparity between the example project code and the README. The code expects me to be using Slash, but the README expects that Dgraph is running locally. So how to I get the project to work without Slash?

The graphQL endpoint will be localhost:8080/graphql if you are running dgraph yourself.

That’s the setup I had used, but it looked like that endpoint wasn’t being used by default. Where should that endpoint be configured?

REACT_APP_GRAPHQL_ENDPOINT=http://localhost:8080/graphql npm start should work.
For brevity, you can set this variable in a new .env file and then just run npm start

The endpoint is picked from the above environment variable.

4 Likes

it works, thank you!

2 Likes