Skip to content

Conversation

p5quared
Copy link
Contributor

Description of changes:

The docs say that default can be applied to scalars and arrays (and not enums), but I believe it should say that it can be applied to scalars and enums (and not arrays).

e.g. this schema will not work npx ampx sandbox:

const schema = a.schema({
  Todo: a
    .model({
      content: a.integer().array().default([1, 2, 3]), // same as "[1, 2, 3]"
    })
    .authorization((allow) => [allow.publicApiKey()]),
});

// Failed to instantiate data construct
// Caused By: The @default directive may only be added to scalar or enum field types.

The actual check in @default is if (isList() || !isScalarOrEnum()) throw;

Instructions

Which product(s) are affected by this PR (if applicable)?

  • amplify-cli
  • amplify-ui
  • amplify-studio
  • amplify-hosting
  • amplify-libraries

Which platform(s) are affected by this PR (if applicable)?

  • JS
  • Swift
  • Android
  • Flutter
  • React Native

Please add the product(s)/platform(s) affected to the PR title
Amplify data schema

Checks

When this PR is ready to merge, please check the box below

  • Ready to merge

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@p5quared p5quared requested a review from a team as a code owner September 25, 2024 22:14
@p5quared p5quared enabled auto-merge (squash) October 4, 2024 02:08
@p5quared p5quared merged commit 121c506 into aws-amplify:main Oct 7, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants