Adding an API with GraphQL and DynamoDB
Now, let's add the GraphQL API to the app by running the amplify add api
command in a Terminal. We will choose a to-do list template as the example for this chapter:
? amplify add api ? Please select from one of the below mentioned services: GraphQL ? Provide API name: my-api-name ? Choose the default authorization type for the API: API key ? Enter a description for the API key: dev ? After how many days from now the API key should expire (1-365): 365 ? Do you want to configure advanced settings for the GraphQL API? No, I am done. ? Do you have an annotated GraphQL schema? No ? Choose a schema template: Single object with fields (e.g., "Todo" with ID, name, description) ? Do you want to edit the schema now? Yes
Before we modify the code, we should call the amplify push
command to trigger the code generator. This will generate the GraphQL code first:
? amplify push ? Do you want to generate code for your newly created...