🚀 Basic starter code for a mobile app based on React Native, GraphQL & Apollo Client.
- Fix runtime issue
- Enable in https://github.com/graphql-cli/graphql-cli/blob/master/src/cmds/create/boilerplates.ts
PRs are very welcome 🙏
- Frontend
- React Native: JavaScript framework for building native mobile apps with React
- Apollo Client: Fully-featured, production ready caching GraphQL client
- Backend
- Graphcool: Powerful GraphQL database
graphql-yoga
: Fully-featured GraphQL server with focus on easy setup, performance & great developer experiencegraphcool-binding
: GraphQL binding for Graphcool services
You need to have the following things installed:
# Bootstrap GraphQL server in directory `my-app`, based on `react-fullstack-basic` boilerplate
graphql create my-app --boilerplate react-native-basic
# Navigate into the new project's `server` directory
cd my-app/server
# Deploy the Graphcool database & start the server (runs on http://localhost:4000)
yarn start
# Navigate back into the project's root directory and launch the React 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)
Alternative: Clone repo
TODO
.graphqlconfig.yml
GraphQL configuration file containing the endpoints and schema configuration. Used by thegraphql-cli
and the GraphQL Playground. Seegraphql-config
for more information.graphcool.yml
: The root configuration file for your database service (documentation).
database/datamodel.graphql
contains the data model that you define for the project (written in SDL).database/schema.generated.graphql
defines the database schema. It contains the definition of the CRUD API for the types in your data model and is generated based on yourdatamodel.graphql
. You should never edit this file manually, but introduce changes only by alteringdatamodel.graphql
and rungraphcool deploy
.
src/schema.graphql
defines your application schema. It contains the GraphQL API that you want to expose to your client applications.src/index.js
is the entry point of your server, pulling everything together and starting theGraphQLServer
fromgraphql-yoga
.
Access to the Graphcool API is secured by a secret. This also applies to the introspection query. Using the latest version of GraphQL Playground, the Authorization
header should automatically be setup with a proper JWT signing the secret. If that's not the case, you can follow these steps to access your API:
- Visit http://jwtbuilder.jamiekurtz.com/
- Replace the
Key
at the bottom of the page with yoursecret
from thegraphcool.yml
- Click
Create signed JWT
and copy the obtained token - Now, to access the schema, use the
Authorization: Bearer <token>
header, or in the GraphQL Playground set it as JSON:{ "Authorization": "Bearer <token>" }
- Reload the schema in the Playground (the refresh-button is located right next to the URL of the server)
Note: Currently, no content of the signed JWT is verified by the database! This will be implemented according to this proposal at a later stage.
Your feedback is very helpful, please share your opinion and thoughts! If you have any questions, join the #graphql-boilerplate
channel on our Slack.