sid88in / serverless-appsync-plugin

serverless plugin for appsync
MIT License
950 stars 186 forks source link

How to avoid the "one-giant-serverless-yml-blob" in v2? #570

Closed thomasmichaelwallace closed 1 year ago

thomasmichaelwallace commented 1 year ago

Hi!

I'm considering the upgrade to v2 from v1.

One of the issues we have is that between all the lambda function definitions, etc. you end up with a massive unnavigable blob of a serverless.yml.

For v1 we worked around this by splitting the mapping templates &c. into categories, which would then define their 10+ query/mutation/field/source/etc. definitions:

  # app sync
  appSync:
    name: name
    # blah, blah, blah, config
    mappingTemplatesLocation: mapping-templates
    mappingTemplates:
      - ${file(./mapping-templates/accounts.yml)}
      - ${file(./mapping-templates/properties.yml)}
      - ${file(./mapping-templates/settings.yml)}
      # blah, blah, blah for another 20 logical categories.
    functionConfigurationsLocation: function-configurations
    functionConfigurations:
      - ${file(./function-configurations/auth.yml)}
      - ${file(./function-configurations/node.yml)}
      # blah, blah, blah
    dataSources:
      - ${file(./data-sources/auth.yml)}
      - ${file(./data-sources/node.yml)}
      # blah, blah, blah

However, I think I understand we can't do that anymore in v2 because the sections are maps not arrays (unless I'm missing something?).

If I fold it all into a single file it's easily 1000s of lines long. Which I guess means either we're the only ones that find it unwieldily, or (equally likely) I'm missing something!

Pointers would be appreciated 😄

bboure commented 1 year ago

@thomasmichaelwallace You should still be able to do that in v2. All properties accept objects or an array of objects 🙂

thomasmichaelwallace commented 1 year ago

Ahh-

My bad - the upgrade guide (https://github.com/sid88in/serverless-appsync-plugin/blob/master/doc/upgrading-from-v1.md) makes such a big thing of them all being defined as a key-value pair object and replacing the array with a key-value pair that I just assumed this feature had been lost.

But I totally missed this approach is mentioned elsewhere: https://github.com/sid88in/serverless-appsync-plugin/blob/master/doc/dataSources.md#organize-your-data-sources .

Thanks for your patience !