|
1 |
| -# Bluemix GraphQL Data Source Base |
| 1 | +# GrAMPS GraphQL Data Source Base |
2 | 2 |
|
3 |
| -- Provides templates for npm, Travis CI, and SonarQube |
4 |
| -- Provides TODO comments next to all items that need to be edited |
5 |
| -- Starts with the simplest possible example code to limit how much boilerplate editing is required |
6 |
| -- Starts you off right with test coverage at 💯 |
7 |
| -- Provides testing helpers for common resolver testing patterns |
8 |
| -- Comes with docs! https://ibm.biz/graphql-data-source |
| 3 | +This is a minimal example and boilerplate for a GrAMPS data source. Inside, you’ll find: |
| 4 | + |
| 5 | + - **Connector** — how to access the data source (e.g. a REST API) |
| 6 | + - **Model** — methods to retrieve/modify data from the data source (e.g. a |
| 7 | + CRUD wrapper) |
| 8 | + - **Schema** — description for GraphQL to interpret the data (see the |
| 9 | + [GraphQL docs on schemas](http://graphql.org/learn/schema/)) |
| 10 | + - **Resolvers** — functions to map the results of calls to model methods to |
| 11 | + the schema |
| 12 | + |
| 13 | +Each file contains a `TODO` comment explaining the changes you’ll need to make to create a working data source. |
| 14 | + |
| 15 | +The goal of this repo is to provide enough code to allow a working example of a data source and its related tests, but to limit how much boilerplate needs to be edited to get your own data source implemented. |
| 16 | + |
| 17 | +## Code Quality and Continuous Integration |
| 18 | + |
| 19 | +To help ensure a reliable, easy-to-maintain data source, this example also includes: |
| 20 | + |
| 21 | + - Configuration for Travis CI (for automated testing) and Code Climate |
| 22 | + (for quality analysis) |
| 23 | + - Starts you off right with test coverage at 💯 |
| 24 | + - Provides testing helpers for common resolver testing patterns |
| 25 | + - Comes with docs! https://ibm.biz/graphql-data-source |
9 | 26 |
|
10 | 27 | ## Quickstart
|
11 | 28 |
|
| 29 | +**NOTE:** Replace all instances of `YOUR_DATA_SOURCE_NAME` with the actual name you want to use (e.g. `data-source-companyname-datatype`). |
| 30 | + |
12 | 31 | ```sh
|
13 | 32 | # Clone the repo
|
14 |
| -git clone git@github.ibm.com:Bluemix/graphql-data-source-base.git graphql-data-source-YOUR_DATA_SOURCE_NAME |
| 33 | +git clone [email protected]: gramps-graphql/data-source-base.git data-source-YOUR_DATA_SOURCE_NAME |
15 | 34 |
|
16 | 35 | # Move into it
|
17 |
| -cd graphql-data-source-YOUR_DATA_SOURCE_NAME/ |
| 36 | +cd data-source-YOUR_DATA_SOURCE_NAME/ |
18 | 37 |
|
19 | 38 | # Change the remote repo
|
20 |
| -git remote set-url origin [email protected]:Bluemix/YOUR_REPO_NAME.git |
21 |
| - |
22 |
| -# Create a package.json |
23 |
| -cp package.TEMPLATE.json package.json |
| 39 | +git remote set-url origin [email protected]:USER_OR_ORG/YOUR_REPO_NAME.git |
24 | 40 |
|
25 |
| -# IMPORTANT: Edit name, description, author, and repository in package.json |
| 41 | +# IMPORTANT: Make sure to edit the name, description, contributors, and |
| 42 | +# repository fields in package.json |
26 | 43 |
|
27 | 44 | # Install dependencies
|
28 |
| -npm install |
| 45 | +yarn install |
29 | 46 | ```
|
30 | 47 |
|
31 |
| -### To Develop In Local Mode |
| 48 | +### To Develop with Mock Data |
32 | 49 |
|
33 | 50 | Start the app with the following command:
|
34 | 51 |
|
35 | 52 | ```sh
|
36 |
| -# Run in local mode with mock data |
37 |
| -npm run local |
| 53 | +# Develop with mock data |
| 54 | +yarn mock-data |
38 | 55 | ```
|
39 | 56 |
|
40 |
| -### To Develop in Atlas Mode |
41 |
| - |
42 |
| -Create `config/app_env_private.json` by duplicating `config/app_env_private.TEMPLATE.json`. Inside, add the required private environment variables. |
43 |
| - |
44 |
| -> **NOTE:** Information on where to get the required environment variables can |
45 |
| -> be found in the "How do I configure my application to use Bluemix?" section |
46 |
| -> of [this FAQ](https://ibm.biz/BdjXjr). |
| 57 | +### To Develop with Live Data |
47 | 58 |
|
48 |
| -Next, start the app in Atlas mode: |
| 59 | +Once you’ve got your data source configured to load live data, you can enable live data in development: |
49 | 60 |
|
50 | 61 | ```sh
|
51 |
| -# Run in Atlas mode with live data |
52 |
| -npm run atlas |
| 62 | +# Develop with live data |
| 63 | +yarn live-data |
53 | 64 | ```
|
54 | 65 |
|
55 | 66 | ### Notes for Developers
|
56 | 67 |
|
57 |
| -Currently, there is no watch capability (PRs welcome!), so the service needs to be stopped (`control` + `C`) and restarted (`npm run [local|atlas]`) to reflect new changes to the data source. |
| 68 | +Currently, there is no watch capability (PRs welcome!), so the service needs to be stopped (`control` + `C`) and restarted (`yarn [mock-data|live-data]`) to reflect new changes to the data source. |
0 commit comments