howtographql/react-urql

Name: react-urql

Owner: How to GraphQL

Description: null

Created: 2018-05-10 07:23:02.0

Updated: 2018-05-18 14:07:31.0

Pushed: 2018-05-15 13:33:46.0

Homepage: null

Size: 119

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

React & urql Tutorial

This is the sample project that belongs to the React & urql Tutorial (Work in Progress) on How to GraphQL.

Running the App
1. Clone repository
clone https://github.com/howtographql/react-urql/
2. Install dependencies & Deploy the Prisma database API
eact-urql/server
 install
 prisma deploy

When prompted where (i.e. to which cluster) you want to deploy your service, choose any of the public clusters, e.g. public-us1 or public-eu1. (If you have Docker installed, you can also deploy locally.)

Note: This repository uses a slightly outdated version of the Prisma CLI and will be updated soon to use the latest release.

3. Set the Prisma API endpoint

From the output of the previous command, copy the HTTP endpoint and paste it into server/src/index.js where it's used to instantiate the Prisma binding. You need to replace the current placeholder __PRISMA_ENDPOINT__:

t server = new GraphQLServer({
peDefs: './src/schema.graphql',
solvers,
ntext: req => ({
...req,
db: new Prisma({
  typeDefs: 'src/generated/prisma.graphql',
  endpoint: '__PRISMA_ENDPOINT__',
  secret: 'mysecret123',
}),
,

For example:

t server = new GraphQLServer({
peDefs: './src/schema.graphql',
solvers,
ntext: req => ({
...req,
db: new Prisma({
  typeDefs: 'src/generated/prisma.graphql',
  endpoint: 'https://eu1.prisma.sh/public-hillcloak-flier-942261/hackernews-graphql-js/dev',
  secret: 'mysecret123',
}),
,

Note that the part public-hillcloak-flier-952361 of the URL is unique to your Prisma API.

4. Start the server

To start the server, all you need to do is install the the dependencies execute the start script by running the following command inside the server directory:

 install
 start

Note: If you want to interact with the GraphQL APIs inside a GraphQL Playground, you can also run yarn dev.

5. Run the app

Now that the server is running, you can start the app as well. The commands need to be run in a new terminal tab/window inside the root directory react-urql (because the current tab is blocked by the process running the server):

 install
 start

You can now open your browser and use the app on http://localhost:3000.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.