Amplify-cli: Best Approach for 'heavy' graphql Schema

Created on 20 Nov 2018  路  7Comments  路  Source: aws-amplify/amplify-cli

* Which Category is your question related to? *
GraphQL Schema + amplify codegen / transformer

* What AWS Services are you utilizing? *

  • AppSync
  • Amplify-cli

* Provide additional details e.g. code snippets *
My schema with 12+ @model can not be push due to CloudFormation stack number and/or template size limitation. (2 of them are related to many-to-many relations)

I can see 3 ways to bypass this problem:

  1. Wait for a release that allow us to push the schema without error (Holy Rollback :))
  2. Complete directly the schema on the AppSync console, but there is no amplify pull option to avoid resynchronization problems
  3. Create a new Graphql endpoint and later merge my schema to have a more conventional 1 schema/1 endpoint. But amplify does not allow me to create a new one, only update the existing one.

Do you have already solve this kind of problem and what was your feedback?
Thanks

graphql-transformer question

Most helpful comment

Hey @MatthieuLab. I am actively working on a change that will add support for nested stacks to the transform to solve for this use case. You are not alone as there have been other issues mentioning this in the past (see #185). We have made good progress but this change impacts a lot of different parts and requires refactoring of our tests etc. This change is blocking a number of other features so is a very high priority item.

All 7 comments

Am I the only one having to solve this?

Hey @MatthieuLab. I am actively working on a change that will add support for nested stacks to the transform to solve for this use case. You are not alone as there have been other issues mentioning this in the past (see #185). We have made good progress but this change impacts a lot of different parts and requires refactoring of our tests etc. This change is blocking a number of other features so is a very high priority item.

@mikeparisstuff thanks for your feedback. Would love to have an ETA.

So what have my team done to solve this?

  1. We update locally our shema.graphql
  2. We generate the resolvers and the schema with amplify api gql-compile
  3. We copy past the generated schema in the AppSync Console & save it.
  4. We update The resolvers for the new model : Query, Mutation. If there is @connection, we also need to update the resolver in the Model Object. All the resolvers are available in the build folder.

If it can help others, it seems to be straight forward and OK.
Carefull, do not push without -no-gql-override flag

Matthieu
PS: I really hope that we'll be able to also have a 'amplify pull' command.

@MatthieuLab Are you using cloudformation to update the resolvers?

@MatthieuLab Are you using cloudformation to update the resolvers?

@rajababu3 nope, directly the AppSync Console with the Create Resource button to create the DynamoDB table (which I suppose is out of the CloudFormation previously created stack)

Some other potential workarounds while we wait...

I was able to run json-minify on cloudformation-template.json just before amplify writes the resource.

I'm sure there's a better way to do it, but I brute forced it by waiting for the "Do you want to generate GraphQL statements..." prompt, then opening a second terminal, then minifying the template.

The template minifies to about a third the original size. This is strictly whitespace removal.

If the json-minify approach is sound, I would suggest modifying the cli to support this. I took a quick look, but wasn't sure where the best place to do so would be.

You can also shrink the size of the template with a more granular model configuration. For example...

type Attachment
@model(mutations: { create: "createAttachment" }, subscriptions: null)

This will stop the creation of subscriptions, and delete/update resolvers. I actually think this is a feature, as I can match the mutations, queries and subscriptions to the natural semantics of the domain model. (Note: removing subscriptions doesn't have a material impact on template size, but the "CRUDL" queries and mutations do).

Closing this issue since it's a duplicate of #185 and the fix for this issue is currently in PR stage.

Was this page helpful?
0 / 5 - 0 ratings