mirror of
https://github.com/kou029w/hasura-rest-hands-on.git
synced 2025-02-23 00:55:16 +00:00
fix
This commit is contained in:
parent
758a1e792b
commit
d81260001b
1 changed files with 9 additions and 9 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
## 設計
|
||||
|
||||
HasuraはGraphQL QueryをREST化することが可能です。このハンズオンでは、次の仕様のREST APIエンドポイントを作成します。
|
||||
HasuraはGraphQL APIサーバーとして利用するだけでなく、REST APIサーバーとして利用することもできます。このハンズオンでは、GraphQL QueryをREST化し、次の仕様のREST APIエンドポイントを作成します。
|
||||
|
||||
| 名称 | HTTPメソッドとパス | 説明 |
|
||||
| ------------ | ------------------------ | ------------------------------------------------------------------------------------------------------------------- |
|
||||
|
@ -15,6 +15,8 @@ HasuraはGraphQL QueryをREST化することが可能です。このハンズオ
|
|||
|
||||
ページを取得するためのREST APIエンドポイントを作成します。
|
||||
|
||||

|
||||
|
||||
コンソールのトップ画面のGraphiQLのパネルにアクセスし、次のコードを書きます。
|
||||
|
||||
```graphql
|
||||
|
@ -26,22 +28,22 @@ query getPage($id: Int!) {
|
|||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
[REST]ボタンを選択し、REST APIエンドポイント作成フォームを表示します。次の必要事項を入力し、作成ボタンを選択しエンドポイントを作成します。
|
||||
|
||||

|
||||
|
||||
| 項目 | 説明 | 内容 |
|
||||
| -------- | ----------------------- | ---------- |
|
||||
| Name | エンドポイントの名称 | get page |
|
||||
| Location | `/api/rest/` 以降のパス | `page/:id` |
|
||||
| Method | HTTPメソッド | `GET` |
|
||||
|
||||

|
||||
|
||||
## 「ページの更新 (`PUT page/:id`)」エンドポイントの作成
|
||||
|
||||
ページを更新するためのREST APIエンドポイントを作成します。
|
||||
|
||||

|
||||
|
||||
コンソールのトップ画面のGraphiQLのパネルにアクセスし、次のコードを書きます。
|
||||
|
||||
```graphql
|
||||
|
@ -56,16 +58,14 @@ mutation putPage($id: Int!, $content: jsonb!) {
|
|||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
[REST]ボタンを選択し、REST APIエンドポイント作成フォームを表示します。次の必要事項を入力し、作成ボタンを選択しエンドポイントを作成します。
|
||||
|
||||

|
||||
|
||||
| 項目 | 説明 | 内容 |
|
||||
| -------- | ----------------------- | ---------- |
|
||||
| Name | エンドポイントの名称 | put page |
|
||||
| Location | `/api/rest/` 以降のパス | `page/:id` |
|
||||
| Method | HTTPメソッド | `PUT` |
|
||||
|
||||

|
||||
|
||||
作成が完了すると作成したREST APIエンドポイントの一覧が表示されます。
|
||||
|
|
Loading…
Add table
Reference in a new issue