Skip to content

Posts

作成したレコードのID取得

イベント作成と一覧が確認できたので、個別表示と編集のためのパラメータを渡す方法を調べる。

参考:

API.graphql の戻り値を見ればよさそうだけど、長いIDだ、、 まあとりあえずはこれで。

router.js にパラメータ追加して、props: trueも設定。

props設定が抜けていて、“Variable ‘id’ has coerced Null value for NonNull type ‘ID!’“エラーに悩まされた。

Read more

CORS続き

昨日、CORSのエラーで躓いていたものの解決ができず。

チュートリアルでやったときも出てたのか、出てなかったのか今となっては確認が面倒。。

問題の切り分けをするため、hostingに上げてみる。

$ amplify add hosting
? Select the plugin module to execute Hosting with Amplify Console (Managed hosting with custom domains, Continuous deployment)
? Choose a type Manual deployment

$ amplify publish

エラーは出ない。やっぱりCodespacesで実行したときの問題らしい。だけど毎回publishするのは時間もかかるしコストもかかるから避けたい。

Read more

データ登録やってみる

データの格納先ができたので、画面からデータ登録できるようにしてみる。

参考:

Codespacesでnpm run serveで実行してアクセスすると、ブラウザのコンソールにInvalid Host/Origin headerが出ている。

package.json を修正して回避。codespaces前提だけど。

    "serve": "vue-cli-service serve --public ${CODESPACE_NAME}.githubpreview.dev",

参考:

次に出たのはCORSのエラー。 今日はここまで。

Read more

schemaファイルを作る

データ構造を考えたので、それをスキーマ情報に落としていく。

の前にamplifyコマンド

$ amplify add api
? Select from one of the below mentioned services: GraphQL
? Here is the GraphQL API that we will create. Select a setting to edit or continue Continue
? Choose a schema template: One-to-many relationship (e.g., “Blogs” with “Posts” and “Comments”)

⚠️  WARNING: your GraphQL API currently allows public create, read, update, and delete access to all models via an API Key. To configure PRODUCTION-READY authorization rules, review: https://docs.amplify.aws/cli/graphql/authorization-rules

GraphQL schema compiled successfully.

Edit your schema at /workspaces/eventsite/amplify/backend/api/eventsite/schema.graphql or place .graphql files in a directory at /workspaces/eventsite/amplify/backend/api/eventsite/schema
✔ Do you want to edit the schema now? (Y/n) · yes
? Choose your default editor: Visual Studio Code
Edit the file in your editor: /workspaces/eventsite/amplify/backend/api/eventsite/schema.graphql
✅ Successfully added resource eventsite locally

✅ Some next steps:
"amplify push" will build all your local backend resources and provision it in the cloud
"amplify publish" will build all your local backend and frontend resources (if you have hosting category added) and provision it in the cloud

schema.graphql ファイルを編集してpush。

Read more

データ構造を考える

各画面で必要な項目からデータ構造を作る。

event

項目名nametype
IDidint
イベント名titlestring
開催日時starttimestamp
開催場所placestring
公開期間Fromopendatetime
公開期間Toclosedatetime
作成者authorint -> user.id

user

項目名nametype
IDidint
ユーザー名usernamestring

eventUser

項目名nametype
IDidint
イベントIDeventidint -> event.id
ユーザーIDuseridint -> user.id

upload

項目名nametype
IDidint
イベントIDeventidint -> event.id
資料URLurlstring

comment

項目名nametype
IDidint
イベントIDeventidint -> event.id
ユーザーIDuseridint -> user.id
コメントcommentstring
投稿日時postedAtdatetime

とりあえずこんな感じかな。

Read more

画面を作る

各画面のファイルができたので、必要な項目を並べていく作業。 uiflow作ったときにおおむね書いておいたので、それをタグに落としていく。

一通り書いて、ボタンで画面遷移もするようにできた。

次はログイン機能をつける(チュートリアルでやったやつ)。

画面モックを作る

昨日洗い出した画面をとりあえず書いてみる。

画面遷移にvue-routerを使うので、インストールしておく。

npm install vue-router

各画面は、src/views/に置く。

 $ ls -1 src/views/
CancelConfirm.vue
EntryConfirm.vue
EventCreate.vue
EventDetail.vue
EventEdit.vue
EventSearch.vue
Login.vue
MyPage.vue
Top.vue

ファイル作るところまでで今日は時間切れ。。