Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
timrchavez opened this Issue Mar 9, 2019 · 3 comments

Comments

Projects
None yet
4 participants
@timrchavez
Copy link

timrchavez commented Mar 9, 2019

** 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

@yuth

This comment has been minimized.

Copy link
Contributor

yuth commented Mar 12, 2019

codegen does not generate input types, but its needed for offline support. We will have to update the codegen to generate input types to make it easier to support offline support

@jkeys-ecg-nmsu

This comment has been minimized.

Copy link

jkeys-ecg-nmsu commented Mar 12, 2019

@yuth could the input types generated by AppSync be downloaded with something like amplify api pull --types?

@yuth

This comment has been minimized.

Copy link
Contributor

yuth commented Mar 12, 2019

@jkeys-ecg-nmsu the compiled schema should already be available to you inside <proj-root>/amplify/backedn/api/<api-name>/build/schema.json and should have the input type.

I have added this issue to our backlog to generate input types. I will try to get to this as soon as this gets prioritized.

@yuth yuth added the pending-review label Mar 12, 2019

@timrchavez timrchavez changed the title How do I generate exportable graphql input types using `aws codegen`? How do I generate exportable graphql input types using `amplify codegen`? Mar 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.