mirror of
https://github.com/kou029w/intro-to-graphql.git
synced 2025-01-19 00:18:08 +00:00
support graphql syntax highlight
This commit is contained in:
parent
3a2ca23188
commit
55ad0d96fc
2 changed files with 62 additions and 42 deletions
2
.github/workflows/github-pages.yml
vendored
2
.github/workflows/github-pages.yml
vendored
|
@ -10,7 +10,7 @@ jobs:
|
||||||
- name: build
|
- name: build
|
||||||
run: |
|
run: |
|
||||||
git -c "user.name=bot" -c "user.email=bot@example" subtree add --prefix pages origin gh-pages
|
git -c "user.name=bot" -c "user.email=bot@example" subtree add --prefix pages origin gh-pages
|
||||||
npx @marp-team/marp-cli README.md -o pages/index.html
|
npx @marp-team/marp-cli README.md --html -o pages/index.html
|
||||||
- id: git_status
|
- id: git_status
|
||||||
run: echo "::set-output name=mod::$(git status pages --porcelain)"
|
run: echo "::set-output name=mod::$(git status pages --porcelain)"
|
||||||
- name: push
|
- name: push
|
||||||
|
|
48
README.md
48
README.md
|
@ -9,6 +9,13 @@ WebDINO Japan エンジニア
|
||||||
[渡邉浩平](https://github.com/kou029w)
|
[渡邉浩平](https://github.com/kou029w)
|
||||||
![w:200](https://github.com/kou029w.png)
|
![w:200](https://github.com/kou029w.png)
|
||||||
|
|
||||||
|
<!-- @license https://cdn.jsdelivr.net/npm/highlightjs-graphql@1.0.2/LICENSE -->
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.1.0/build/styles/default.min.css">
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.1.0/build/highlight.min.js"></script>
|
||||||
|
<script>module={};</script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/highlightjs-graphql@1.0.2/graphql.min.js"></script>
|
||||||
|
<script>hljs.registerLanguage("graphql", hljsDefineGraphQL);hljs.highlightAll();</script>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## GraphQL とは
|
## GraphQL とは
|
||||||
|
@ -20,6 +27,7 @@ https://graphql.org
|
||||||
### GraphQL とは API のクエリ言語
|
### GraphQL とは API のクエリ言語
|
||||||
|
|
||||||
サーバーへの問い合わせ (GraphQL Query)
|
サーバーへの問い合わせ (GraphQL Query)
|
||||||
|
|
||||||
```graphql
|
```graphql
|
||||||
query {
|
query {
|
||||||
pokemon(name: "Pikachu") {
|
pokemon(name: "Pikachu") {
|
||||||
|
@ -29,6 +37,7 @@ query {
|
||||||
```
|
```
|
||||||
|
|
||||||
サーバーからの応答 (JSON)
|
サーバーからの応答 (JSON)
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
|
@ -61,6 +70,7 @@ https://graphql-pokemon2.vercel.app
|
||||||
- [クエリの実行方法](https://graphql.org/learn/execution/)
|
- [クエリの実行方法](https://graphql.org/learn/execution/)
|
||||||
|
|
||||||
### GraphQL 以外の身近な言語の例:
|
### GraphQL 以外の身近な言語の例:
|
||||||
|
|
||||||
- クエリ言語: SQL
|
- クエリ言語: SQL
|
||||||
- スキーマ言語: [JSON Schema](https://json-schema.org/), [XSD](http://www.w3.org/TR/xmlschema11-1/)
|
- スキーマ言語: [JSON Schema](https://json-schema.org/), [XSD](http://www.w3.org/TR/xmlschema11-1/)
|
||||||
|
|
||||||
|
@ -163,18 +173,28 @@ type PokemonDimension {
|
||||||
---
|
---
|
||||||
|
|
||||||
```graphql
|
```graphql
|
||||||
"""ポケモンを表します"""
|
"""
|
||||||
|
ポケモンを表します
|
||||||
|
"""
|
||||||
type Pokemon {
|
type Pokemon {
|
||||||
"""このオブジェクトのID"""
|
"""
|
||||||
|
このオブジェクトのID
|
||||||
|
"""
|
||||||
id: ID!
|
id: ID!
|
||||||
|
|
||||||
"""このポケモンの名前"""
|
"""
|
||||||
|
このポケモンの名前
|
||||||
|
"""
|
||||||
name: String
|
name: String
|
||||||
|
|
||||||
"""このポケモンの分類"""
|
"""
|
||||||
|
このポケモンの分類
|
||||||
|
"""
|
||||||
classification: String
|
classification: String
|
||||||
|
|
||||||
"""このポケモンの高さの最大と最小"""
|
"""
|
||||||
|
このポケモンの高さの最大と最小
|
||||||
|
"""
|
||||||
height: PokemonDimension
|
height: PokemonDimension
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -190,7 +210,7 @@ type Pokemon {
|
||||||
const pokemonQuery = `{ pokemon(name: "Pikachu") { classification } }`;
|
const pokemonQuery = `{ pokemon(name: "Pikachu") { classification } }`;
|
||||||
|
|
||||||
fetch(`http://example/?${new URLSearchParams({ query: pokemonQuery })}`)
|
fetch(`http://example/?${new URLSearchParams({ query: pokemonQuery })}`)
|
||||||
.then(r => r.json())
|
.then((r) => r.json())
|
||||||
.then(({ data }) => console.log(data?.pokemon?.classification));
|
.then(({ data }) => console.log(data?.pokemon?.classification));
|
||||||
// => "Mouse Pokémon"
|
// => "Mouse Pokémon"
|
||||||
```
|
```
|
||||||
|
@ -488,13 +508,13 @@ HTTP GETメソッドによる一般的な[HTTP キャッシュ](https://develope
|
||||||
|
|
||||||
### JSON Serialization
|
### JSON Serialization
|
||||||
|
|
||||||
GraphQL Value |JSON Value
|
| GraphQL Value | JSON Value |
|
||||||
---|---
|
| ----------------- | ------------- |
|
||||||
Map |Object
|
| Map | Object |
|
||||||
List |Array
|
| List | Array |
|
||||||
Null |null
|
| Null | null |
|
||||||
String/Enum Value |String
|
| String/Enum Value | String |
|
||||||
Boolean |true or false
|
| Boolean | true or false |
|
||||||
Int/Float |Number
|
| Int/Float | Number |
|
||||||
|
|
||||||
https://spec.graphql.org/June2018/#sec-JSON-Serialization
|
https://spec.graphql.org/June2018/#sec-JSON-Serialization
|
||||||
|
|
Loading…
Add table
Reference in a new issue