Amplify-cli: amplify api gql-compile: Docs improvement suggestion

Created on 27 Aug 2018  Â·  13Comments  Â·  Source: aws-amplify/amplify-cli

Right now, the docs on what the amplify api gql-compilecommand does are a little sparse.

From https://github.com/aws-amplify/amplify-cli/blob/master/packages/amplify-category-api/Readme.md

Compiles your GraphQL schema and generates a corresponding cloudformation template.

I'd love a bit more content here describing how updates to an existing and already-pushed schema behave. For example, if I add a new @model type to my schema, does it create a new datasource and resolvers just for that new type?

documentation graphql-transformer

Most helpful comment

Thanks, @mikeparisstuff -- Another related question. If I want to make changes to any of the generated resolvers, can I make local edits and then run a command to push my changes out? It seems like amplify api push will overwrite any changes I make to local resolvers during its push. Also seems like if I edit a resolver directly on the AppSync console, there's currently no way to pull edits and sync them with the local files. Is this correct? I'm looking for a workflow that supports keeping canonical resolver definitions as part of my project's code (versus living only in AppSync's console).

All 13 comments

These are great suggestions and we will make sure to include these docs. To answer those specific questions now, the only thing you need to do after updating your schema.graphql is run amplify api push. You may run amplify api gql-compile which will run the schema through the transform and update the files locally in the api's build folder but push also does this before pushing.

Thanks, @mikeparisstuff -- Another related question. If I want to make changes to any of the generated resolvers, can I make local edits and then run a command to push my changes out? It seems like amplify api push will overwrite any changes I make to local resolvers during its push. Also seems like if I edit a resolver directly on the AppSync console, there's currently no way to pull edits and sync them with the local files. Is this correct? I'm looking for a workflow that supports keeping canonical resolver definitions as part of my project's code (versus living only in AppSync's console).

+1 for this one, 😄 I can't find a good solution for setting up my resolvers manually.
I'm trying to set up complex objects but I cant figure it out how I can do that locally.
Also looking for the pull feature

+1. Maybe as a stop-gap, 'amplify api push' shouldn't automatically run 'amplify api gql-compile'. Or maybe just provide us another command to push the existing cloudformation template (modified by us) without doing gql-compile and overwriting everything.

@mikeparisstuff - Does my second question above (https://github.com/aws-amplify/amplify-cli/issues/30#issuecomment-416429148) also fall into the work surrounding CI/CD workflows being discussed here: https://github.com/aws-amplify/amplify-cli/issues/286 ?

Looks like the feature I mentioned https://github.com/aws-amplify/amplify-cli/issues/30#issuecomment-416429148 is being discussed / WIPed here: https://github.com/aws-amplify/amplify-cli/issues/74

@caki0915 There are docs on using S3 with Amplify here https://aws-amplify.github.io/docs/js/graphql#s3-objects

Thanks, @mikeparisstuff -- Another related question. If I want to make changes to any of the generated resolvers, can I make local edits and then run a command to push my changes out? It seems like amplify api push will overwrite any changes I make to local resolvers during its push. Also seems like if I edit a resolver directly on the AppSync console, there's currently no way to pull edits and sync them with the local files. Is this correct? I'm looking for a workflow that supports keeping canonical resolver definitions as part of my project's code (versus living only in AppSync's console).

Does anyone have an answer to this?

@Matthcw Take a look at https://github.com/aws-amplify/amplify-cli/issues/574 for a proposal for custom resolver editing

@Matthcw @gabehollombe-aws
We introduced a new flag with CLI version 0.1.29 for the amplify push command - ‘amplify push —no-gql-override’ which wouldn’t override your local resolvers/CFN changes on a push.

@kaustavghosh06 , thanks for the good news. Can you please elaborate a little bit more on amplify push —no-gql-override command? How exactly it works?

Suppose, I made some changes in the auto-generated resolvers via AppSync console and also added new graphql type locally. Now I issue amplify push —no-gql-override. What will happen? Will my new type be added?

Hey guys,
We've added functionality for custom resolvers. Please use npm install -g @aws-amplify/cli to install the latest version of the CLI. For documentation regarding it, please refer to https://aws-amplify.github.io/docs/cli/graphql#overwrite-a-resolver-generated-by-the-graphql-transform

Here's the launch announcement for the same - https://aws.amazon.com/blogs/mobile/amplify-adds-support-for-multiple-environments-custom-resolvers-larger-data-models-and-iam-roles-including-mfa/

is there any way to revert the local resources generated by amplify api gql-compile?
One way could be to checkout to a new environment but would be awesome if there's a built-in command

Was this page helpful?
0 / 5 - 0 ratings

Related issues

darrentarrant picture darrentarrant  Â·  3Comments

amlcodes picture amlcodes  Â·  3Comments

ReidWeb picture ReidWeb  Â·  3Comments

nason picture nason  Â·  3Comments

YikSanChan picture YikSanChan  Â·  3Comments