}
94 | >
95 | );
96 | }
97 |
98 | export default App
99 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started
2 |
3 | To start this project please first create a `.env` file in the root of your project with the following:
4 |
5 | ```
6 | REACT_APP_ASTRA_TOKEN={your_astra-token}
7 | ```
8 |
9 | In your Datastax Astra Dashboard, create a keyspace called 'coins'. Then navigate to your GraphQL playground and make sure you are at the endpoint ending with graphql-admin.
10 |
11 | Eg: `https://5892dddf-ff9a-4b40-aa31-aa97de1a0966-westeurope.apps.astra.datastax.com/api/graphql-admin`
12 |
13 | Once there, make sure to add the following to the HTTP Header to authorize access:
14 |
15 | ```
16 | {
17 | "x-cassandra-token": {your_astra-token}
18 | }
19 | ```
20 |
21 | And deploy the following Schema:
22 |
23 | ```
24 | mutation {
25 | deploySchema(
26 | keyspace: "coins"
27 | schema: """
28 | type Coin @key @cql_input {
29 | asset_id: String! @cql_column(partitionKey: true)
30 | name: String
31 | category: String @cql_index
32 | price_usd: Float
33 | }
34 | type Mutation {
35 | insertCoin(coin: CoinInput): Coin
36 | }
37 | type Query {
38 | coinsByAssetIds(
39 | asset_ids: [String] @cql_where(field: "asset_id", predicate: IN)
40 | ): [Coin]
41 | coinsByCategory(
42 | category: String
43 | ): [Coin]
44 | }
45 | """
46 | ) {
47 | version
48 | }
49 | }
50 | ```
51 |
52 | Next, go to the endpoint with your keyspace name:
53 |
54 | Eg: `https://5892dddf-ff9a-4b40-aa31-aa97de1a0966-westeurope.apps.astra.datastax.com/api/graphql/coins`
55 |
56 | And create some coins:
57 | ```
58 | mutation {
59 | c1: insertCoin(
60 | coin: {
61 | asset_id: "BTC"
62 | name: "Bitcoin"
63 | category: "Crypto"
64 | price_usd: 30724.60
65 | }
66 | ) {
67 | asset_id
68 | }
69 | c2: insertCoin(
70 | coin: {
71 | asset_id: "ETH"
72 | name: "Ethereum"
73 | category: "Crypto"
74 | price_usd: 1817.46
75 | }
76 | ) {
77 | asset_id
78 | }
79 | c3: insertCoin(
80 | coin: {
81 | asset_id: "GBP"
82 | name: "Great British Pounds"
83 | category: "Currency"
84 | price_usd: 1.37
85 | }
86 | ) {
87 | asset_id
88 | }
89 | }
90 | ```
91 |
92 |
93 | To run this project please type the following commands:
94 |
95 | ### `npm i`
96 |
97 | This will install all the necessary dependencies.
98 |
99 | ### `npm run start-deals`
100 |
101 | This will start the Deals Service on [http://localhost:4001](http://localhost:4001)
102 |
103 | ### `npm run start-gateway` (in a new tab)
104 |
105 | This will start the gateway with data from both the Deals Service and DataStax on [http://localhost:4000](http://localhost:4000)
106 |
107 | ### `npm run start` (in a new tab)
108 |
109 | Runs the app in the development mode.\
110 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
111 |
112 | The page will reload if you make edits.\
113 | You will also see any lint errors in the console.
114 |
115 | To learn React, check out the [React documentation](https://reactjs.org/).
116 |
117 |
118 | ### MIT Licence
119 |
120 | Copyright (c) 2020 Ania Kubow
121 |
122 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
123 |
124 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
125 |
126 | *Translation: Ofcourse you can use this for you project! Just make sure to say where you got this from :)
127 |
128 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
129 |
--------------------------------------------------------------------------------