aws-amplify / aws-amplify/amplify-codegen

How do I generate exportable graphql input types using `amplify codegen`?

Open
#44 7 comments 4 reactions 0 assignees View on GitHub
doc-gen feature-request p4 plugins-support
Dominant language
TypeScript
Stars
59
Forks
64
PR merge metrics
No merged PRs in 30d

Description

** Which Category is your question related to? **

codegen

** What AWS Services are you utilizing? **

appsync, dynamodb

** Provide additional details e.g. code snippets **

I'm trying to follow the documentation here https://aws-amplify.github.io/docs/js/api#aws-appsync-sdk and there is an example for using `buildMutation` given:

```
import { listTodos } from './graphql/queries';
import { createTodo, CreateTodoInput } from './graphql/mutations';

(async () => {
const result = await client.mutate(buildMutation(client,
gql(createTodo),
{
inputType: gql(CreateTodoInput),
variables: {
input: {
name: 'Use AppSync',
description: 'Realtime and Offline',
}
}
},
(_variables) => [ gql(listTodos) ],
'Todo'));

console.log(result);
})();
```

Specifically, `import { createTodo, CreateTodoInput } from './graphql/mutations';`

When I run `amplify codegen`, the generated `src/graphql/mutations.js` does *not* include `input` types (e.g. CreateTodoInput in the case of the example given). How do I generate these, so I can use `buildMutation` in a similar manner?

Just noticed I used `aws` instead of `amplify` everywhere. My bad :) `aws` mindshare is strong

Contributor guide

Open the contributing guide

Research direction

Start with the documented buildMutation example at the AWS Amplify API link and compare it with the generated src/graphql/mutations.js produced by amplify codegen. Check whether the codegen entry point supports exporting input types such as CreateTodoInput, then clarify the supported workflow or update the documentation so the example matches generated output.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api, documentation, tooling
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.