-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: code examples & most remaining slideS
- Loading branch information
1 parent
3162c94
commit e5a76db
Showing
30 changed files
with
15,729 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
### Introspection | ||
|
||
(show basic introspection) | ||
|
||
```graphql | ||
{ | ||
__schema { | ||
types { | ||
name | ||
} | ||
} | ||
} | ||
``` | ||
|
||
After that, show how `useDisableIntrospection()` works by simply uncommenting it and reloading the page. | ||
|
||
### Circular Queries | ||
|
||
(show users query with 5 fields and nested posts, author, posts and author) | ||
|
||
```graphql | ||
query { | ||
users { | ||
id | ||
name | ||
age | ||
posts { | ||
id | ||
title | ||
body | ||
published | ||
author { | ||
id | ||
name | ||
age | ||
posts { | ||
id | ||
title | ||
author { | ||
id | ||
posts { | ||
author { | ||
id | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Apollo Client demo | ||
|
||
(little example how it looks in reality in frontend) | ||
|
||
1. `yarn start` in `graphql-prisma` | ||
2. `yarn start` in `apollo-client` | ||
3. Open `localhost:1234` | ||
|
||
### Testing demo | ||
|
||
(shortly show tested 1 of each: query, mutation, and subscription) | ||
|
||
1. `cd _code` | ||
2. `cd unit-testing` | ||
3. `yarn test` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"scripts": { | ||
"start": "parcel src/index.html" | ||
}, | ||
"devDependencies": { | ||
"parcel-bundler": "^1.12.5" | ||
}, | ||
"dependencies": { | ||
"@apollo/client": "^3.8.8", | ||
"apollo-boost": "^0.1.14", | ||
"graphql": "^16.8.1", | ||
"react": "^18.2.0" | ||
}, | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<div id="users"></div> | ||
<div id="posts"></div> | ||
<script src="./index.js" type="application/javascript"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ApolloClient, InMemoryCache, gql } from "@apollo/client"; | ||
|
||
const client = new ApolloClient({ | ||
uri: "http://localhost:4000/graphql", | ||
cache: new InMemoryCache(), | ||
}); | ||
|
||
const getUsers = gql` | ||
query { | ||
users { | ||
id | ||
name | ||
} | ||
} | ||
`; | ||
|
||
client | ||
.query({ | ||
query: getUsers, | ||
}) | ||
.then((response) => { | ||
let html = ""; | ||
|
||
response.data.users.forEach((user) => { | ||
html += ` | ||
<div> | ||
<h3>${user.name}</h3> | ||
</div> | ||
`; | ||
}); | ||
|
||
document.getElementById("users").innerHTML = html; | ||
}); |
Oops, something went wrong.