Skip to content

Conversation

@dpilch
Copy link
Contributor

@dpilch dpilch commented Oct 17, 2024

Description of changes

Add additional metrics metadata for authorizationMode and customOperations. The metric data is stored in the CFN stack description.

{
  "metadata": {
    "dataSources": "dynamodb,mysql,postgres", // exists today

    // new fields below
    /*
      Possible options
      'aws_iam',
      'openid_connect',
      'amazon_cognito_identity_pools',
      'amazon_congnito_user_pools',
      'api_key',
      'aws_lambda',
    */
    "authorizationModes", "api_key,aws_lambda",
    "customOperations": "queries,mutations"
  }
}
CDK / CloudFormation Parameters Changed

The metrics are stored in the CFN description. No real functional change, but the descriptions will be updated.

Issue #, if available

N/A

Description of how you validated changes

  • Unit tests

Checklist

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

const template = Template.fromStack(stack);
expect(JSON.parse(template.toJSON().Description).metadata).toMatchInlineSnapshot(`
Object {
"authorizationModes": "api_key,aws_iam,aws_lambda",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This asserts order as well as content -- is that intentional?

apiKeyConfig: 'api_key',
lambdaConfig: 'aws_lambda',
};
const authModes = Object.keys(authorizationModes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the tests above asserts the order of the auth mode metric. Is that intentional? Should we sort the values here so we can provide a stable value irrespective of the order in which they are declared?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I will apply a sort.


export const getMetadataCustomOperations = (definition: IAmplifyGraphqlDefinition): string => {
const customOperations: string[] = [];
if (definition.schema.includes('type Query')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not subscriptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't in the product requirements, but we should probably just add it.

@palpatim
Copy link
Member

As far as I can tell this is a typo in the PR description, but calling it out in case:

    /*
      Possible options
      'aws_iam',
      'openid_connect',
      'amazon_cognito_identity_pools',
      'amazon_congnit_user_pools',
      'api_key',
      'aws_lambda',
    */

@dpilch
Copy link
Contributor Author

dpilch commented Oct 18, 2024

Yes, typo in the description. We can see amazon_congnito_user_pools is set correctly in the unit test.

@dpilch dpilch marked this pull request as ready for review October 18, 2024 19:32
@dpilch dpilch requested a review from a team as a code owner October 18, 2024 19:32
@dpilch dpilch enabled auto-merge (squash) October 21, 2024 14:14
@dpilch dpilch merged commit 5571a90 into main Oct 21, 2024
7 checks passed
@dpilch dpilch deleted the metrics-metadata branch October 21, 2024 19:19
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.

3 participants