Skip to content
This repository was archived by the owner on Oct 23, 2018. It is now read-only.

[WIP] Move to Primsa #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 35 additions & 25 deletions basic/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@

# react-native-apollo-basic
# react-native-fullstack-graphql-basic

🚀 Basic starter code for a mobile app based on React Native, GraphQL & Apollo Client.

## TODO

- [ ] Fix runtime issue
- [ ] Enable in [https://github.com/graphql-cli/graphql-cli/blob/master/src/cmds/create/boilerplates.ts](https://github.com/graphql-cli/graphql-cli/blob/master/src/cmds/create/boilerplates.ts)

> **PRs are very welcome** 🙏

## Technologies

* **Frontend**
* [React Native](https://facebook.github.io/react-native/): JavaScript framework for building native mobile apps with [React](https://facebook.github.io/react/)
* [Expo](https://expo.io): Free and open source toolchain build around React Native to help you build native iOS and Android projects using JavaScript and React.
* [Apollo Client](https://github.com/apollographql/apollo-client): Fully-featured, production ready caching GraphQL client
* **Backend**
* [Graphcool](https://www.graph.cool): Powerful GraphQL database
* [Prisma](https://www.prismagraphql.com): Turns your database into a GraphQL API
* [`graphql-yoga`](https://github.com/graphcool/graphql-yoga/): Fully-featured GraphQL server with focus on easy setup, performance & great developer experience
* [`graphcool-binding`](https://github.com/graphcool/graphcool-binding): GraphQL binding for Graphcool services
* [`prisma-binding`](https://github.com/graphcool/prisma-binding): [GraphQL binding](https://blog.graph.cool/reusing-composing-graphql-apis-with-graphql-bindings-80a4aa37cff5) for Prisma services

## Requirements

Expand All @@ -27,39 +21,55 @@ You need to have the following things installed:
* [Expo](https://expo.io/)
* Node 8+
* GraphQL CLI: `npm i -g graphql-cli`
* GraphQL Playground desktop app (optional): [Download](https://github.com/graphcool/graphql-playground/releases)

## Getting started

```sh
# Bootstrap GraphQL server in directory `my-app`, based on `react-fullstack-basic` boilerplate
# 1. Bootstrap GraphQL server in directory `my-app`, based on `react-native-basic` boilerplate
graphql create my-app --boilerplate react-native-basic

# Navigate into the new project's `server` directory
# 2. When prompted, choose the Prisma cluster you want to deploy to
# e.g. prisma-eu1 or prisma-us1 to deploy to a public cluster (recommended)
# or locally (requires Docker)

# 3. Navigate into the `server` directory of the new project
cd my-app/server

# Deploy the Graphcool database & start the server (runs on http://localhost:4000)
yarn start
# 4. Start the server
yarn start # the server is now running on http://localhost:4000

# Navigate back into the project's root directory and launch the React app
# 5. Open a new tab in the terminal and navigate back into my-app
# then run the app
cd ..
yarn run ios # open with iOS simulator
# yarn run android # open with Android emulator
# yarn start # open using the Expo app on your phone (does not work when server is deployed locally)
```
yarn start

<details>
# 6. Open the app in a simulator or device of your choice
# open using the Expo app on your phone (does not work when server is deployed locally)
```

<summary>Alternative: Clone repo</summary>
If you'd rather not use `graphql-cli`, follow these instructions:

```sh
TODO
# 1.
```

</details>

## Docs

### Commands

#### While in the `server` folder

* `yarn start` starts GraphQL server on `http://localhost:4000` (only allows access to the _application_)
* `yarn dev` starts GraphQL server and opens the GraphQL Playground for the `projects` defined in [`.graphqlconfig.yml`](./.graphqlconfig.yml)
* `yarn playground` opens the GraphQL Playground for the `projects` defined in [`.graphqlconfig.yml`](./.graphqlconfig.yml)
* `yarn prisma <subcommand>` access to local version of Prisma CLI (e.g. `yarn prisma deploy`)

#### While no in the `server` folder

* `yarn start`
* `yarn run ios` opens the iOS Simulator
* `yarn run android` opens the Android emulator

### Project structure

#### `/server`
Expand Down
4 changes: 2 additions & 2 deletions basic/server/.graphqlconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ projects:
endpoints:
default: "http://localhost:4000"
database:
schemaPath: "database/schema.generated.graphql"
schemaPath: "src/generated/prisma.graphql"
extensions:
graphcool: graphcool.yml
prisma: database/prisma.yml
7 changes: 3 additions & 4 deletions basic/server/database/datamodel.graphql
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
type Post {
id: ID! @unique
createdAt: DateTime!
updatedAt: DateTime!
description: String!
imageUrl: String!
isPublished: Boolean!
title: String!
text: String!
}
11 changes: 5 additions & 6 deletions basic/server/graphcool.yml → basic/server/database/prisma.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ service: graphql-boilerplate

# the cluster and stage the service is deployed to
stage: dev
cluster: local

# the file path pointing to your data model
datamodel: database/datamodel.graphql
# to disable authentication:
# disableAuth: true
secret: mysecret123

# to enable authentication, provide
# secret: mysecret123
disableAuth: true
# the file path pointing to your data model
datamodel: datamodel.graphql
155 changes: 0 additions & 155 deletions basic/server/database/schema.generated.graphql

This file was deleted.

22 changes: 21 additions & 1 deletion basic/server/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
{
"name": "myapp21",
"name": "graphql-boilerplate",
"scripts": {
<<<<<<< Updated upstream
"start": "graphcool deploy && node src/index.js"
},
"dependencies": {
"graphcool-binding": "1.3.5",
"graphql-yoga": "1.2.0"
=======
"dev": "npm-run-all --parallel start playground",
"start": "node src/index.js",
"playground": "prisma playground"
},
"dependencies": {
"graphql-yoga": "1.2.0",
"prisma-binding": "1.4.0"
},
"devDependencies": {
"graphql-cli": "2.12.4",
"npm-run-all": "4.1.2",
"prisma": "1.0.8"
},
"prettier": {
"semi": false,
"singleQuote": true,
"trailingComma": "all"
>>>>>>> Stashed changes
}
}
Loading