Skip to content

Commit cd924da

Browse files
committed
update README and add .env to .gitignore
1 parent 8204888 commit cd924da

File tree

2 files changed

+49
-14
lines changed

2 files changed

+49
-14
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ data
4141

4242
#build
4343
dist/
44+
45+
.env

README.md

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# GraphQL API Fundamentals
22

3-
This exercise is part of the [React GraphQL Academy](http://reactgraphql.academy) learning material. The goal of the exercise is to help you get started transitioning from REST to GraphQL.
3+
This exercise is part of the [React GraphQL Academy](http://reactgraphql.academy) training material.
44

55
## Our teaching method
66

@@ -23,6 +23,8 @@ More on our [teaching method](https://reactgraphql.academy/blog/react-graphql-ac
2323

2424
## Exercise part 1
2525

26+
🎯 The goal of this exercise it to help you get familiar with GraphQL queries and the in-browser IDE Playground.
27+
2628
Given the following [GraphQL API](https://us-central1-rga-mocked-apis.cloudfunctions.net/graphql):
2729

2830
- Query a list with all the training and retrieve the title and language for each
@@ -32,8 +34,6 @@ Given the following [GraphQL API](https://us-central1-rga-mocked-apis.cloudfunct
3234

3335
## Exercise part 2
3436

35-
### To get started
36-
3737
We are going to create our own GraphQL API on top of this [REST API](https://api.reactgraphql.academy/rest/trainings)
3838

3939
- `git clone https://github.com/reactgraphqlacademy/graphql-api-training.git`
@@ -44,10 +44,10 @@ We are going to create our own GraphQL API on top of this [REST API](https://api
4444

4545
### 🥑 Before we start
4646

47-
- Don't forget to checkout the `fundamentals-v2` branch, install the dependencies, and let me walk you through the code meanwhile.
47+
- Don't forget to checkout the `fundamentals-v2` branch, and install the dependencies.
4848
- We use nodemon in the `start` script, so every time you save, the server will restart automatically.
49-
- The `src/index.js` is the [getting started tutorial](https://www.apollographql.com/docs/apollo-server/getting-started/) from Apollo.
50-
- Let's replace the schema:
49+
- The `src/index.js` is the [getting started tutorial](https://www.apollographql.com/docs/apollo-server/getting-started/) from Apollo. Let me walk you through our code.
50+
- Let's do a small exercise to warm up, let's replace in the schema:
5151

5252
```graphql
5353
type Query {
@@ -63,10 +63,12 @@ type Query {
6363
}
6464
```
6565

66-
What do we need to change so the field avocados returns the array of books when we run the query? ⏳I'll give you 2 minutes to fix it.
66+
🏋️‍♀️ Mini exercise. What do we need to change so the field avocados returns the array of books when we run the query? ⏳ You have 2 minutes to fix it.
6767

6868
### Tasks
6969

70+
🎯 The goal of the following tasks it to help you get familiar with the Schema Definition Language (SDL) and the resolvers.
71+
7072
⚠️ Some info before you start the tasks:
7173

7274
- You can define an array using square brackets and the type, example `[Book]`
@@ -147,7 +149,7 @@ const resolvers = {
147149

148150
We could also create a new field that returns the upper case version of the title without changing the title field. Example:
149151

150-
⚠️ Learners implement (⏳ only 5 minutes to implement and write a query to test it!):
152+
⚠️ Learners implement (⏳ you only 5 minutes to implement and write a query to test it!):
151153

152154
```graphql
153155
type Training {
@@ -201,6 +203,8 @@ query authorName {
201203

202204
### Tasks
203205

206+
🎯 The goal of the following tasks it to help you understand how arguments and relationships work in GraphQL.
207+
204208
To complete the tasks you'll use the helper functions that are at the bottom of the file `src/index.js`
205209

206210
- [ ] 4. Implement a new field in the `Query` type that returns a single training given an id. You need to fetch the training from this endpoint `https://api.reactgraphql.academy/rest/trainings/` + `id`. 🕵️‍♂️ Hint, you need to pass [arguments](https://graphql.org/graphql-js/passing-arguments/) to the field, and then use the second argument in the resolver. There is a helper function at the bottom of `src/index.js`.
@@ -243,28 +247,53 @@ query getTraining {
243247

244248
#### 🏋️‍♀️ Bonus exercise part 3
245249

246-
Create the types and resolvers so the following query works:
250+
- [ ] Bonus 1. Create the types and resolvers so the following query works:
247251

248252
```graphql
249-
query getDangerousDiscount {
253+
query getPotentiallyDangerousDiscount {
250254
discount(id: "dis:421") {
251255
code
252256
training {
253257
title
254258
discounts {
255259
code
256-
# why this query could be dangerous?
260+
# why this type of query could be potentially dangerous?
257261
}
258262
}
259263
}
260264
}
261265
```
262266

263-
Bonus final questions:
264-
265-
- Once the getDangerousDiscount query is implemented, do you see any problem/ vulnerability issues on that query?
267+
- Once the getPotentiallyDangerousDiscount query is implemented, do you see any problem/ vulnerability issues on that type of query?
266268
- Should the relationship Discount to Training be non-nullable? Meaning `training: Training` or `training: Training!`
267269

270+
* [ ] Bonus 2. If we run the following query, is the GraphQL Server fetching the training from the rest API (you can use a console.log in the resolver)?
271+
272+
```graphql
273+
query {
274+
discount(id: "dis:421") {
275+
code
276+
# with the training field commented out, is the training resolver invoked on the API?
277+
# training {
278+
# title
279+
# }
280+
}
281+
}
282+
```
283+
284+
- [ ] Bonus 3. Add a `first` argument to the field discounts in the `Training` object type. The `first` argument is an integer that makes the field `discounts` return the first N discounts, being N the value of the argument. Once implemented, you should be able to run the following query
285+
286+
```graphql
287+
query getTraining {
288+
training(id: "tra:22") {
289+
title
290+
discounts(first: 2) {
291+
code
292+
}
293+
}
294+
}
295+
```
296+
268297
🤸🏾Do you want some extra workout? Create an [enumeration](https://graphql.org/learn/schema/#enumeration-types) for the languages. Add field language to the Training object type that uses the language enum.
269298

270299
## 🧘‍♀️Homework
@@ -298,3 +327,7 @@ You are going to build a GraphQL API on top of an existing REST API. Steps:
298327
## License
299328

300329
This material is available for private, non-commercial use under the [GPL version 3](http://www.gnu.org/licenses/gpl-3.0-standalone.html).
330+
331+
```
332+
333+
```

0 commit comments

Comments
 (0)