-
Notifications
You must be signed in to change notification settings - Fork 421
feat(data-classes): AppSync Resolver Event #323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(data-classes): AppSync Resolver Event #323
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #323 +/- ##
=========================================
Coverage 99.88% 99.88%
=========================================
Files 92 94 +2
Lines 3356 3519 +163
Branches 165 172 +7
=========================================
+ Hits 3352 3515 +163
Misses 2 2
Partials 2 2
Continue to review full report at Codecov.
|
hey @awsed - could you take a quick peek at this PR in case we're missing anything obvious from the Lambda Resolver event object? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks mostly great - only one-liner that could be more readable to ease maintenance by others.
Docs are lacking on confirming the two variants of object, as you pointed out - Amplify GraphQL Transformer vs AppSync Direct Lambda Resolvers.
Hopefully @awsed or @dabit3 have a few minutes to confirm whether there is a good complete event available for each in the docs somewhere
aws_lambda_powertools/utilities/data_classes/appsync_resolver_event.py
Outdated
Show resolved
Hide resolved
aws_lambda_powertools/utilities/data_classes/appsync_resolver_event.py
Outdated
Show resolved
Hide resolved
Note to self - Validate how AppSync Direct Lambda resolvers event look like compared to what Amplify |
This is a better event with the info object: https://github.com/aws/aws-sam-cli/blob/develop/samcli/lib/generated_sample_events/events/appsync/AppSyncDirectResolver.json |
Thanks @awsed i will add that to the test suite, interesting how it differs from what Amplify generates. |
@michaelbrewer the |
yes, that does not come through for Amplify AppSync events. |
@heitorlessa can you run through this again @awsed - i have added all of the optional fields that might be in direct appsync calls. |
Changes: * Add helper functions to generate GraphQL scalar types * AppSyncResolver decorator which works with AppSyncResolverEvent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heitorlessa hopefully this is looking for merging
Looking :) Is the PR description ready? I'll use that for the docs later |
The description progressed over time as i found more things. I can put in a checklist of changes. For the data-classes docs in general we could start to expand on the examples, but that could warrant a who cookbook section. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions on wording, a suggestion to follow what you did with Cognito data classes so including utils is cleaner, and a question on whether it's best to leave AppSyncResolver decorator out until we have a more complete written RFC for discussion?
Whatever we decide on AppSyncResolver will open precedent to discuss API Gateway Lightweight decorators too, for things like CORS, HTTP Methods, etc.
aws_lambda_powertools/utilities/data_classes/appsync_resolver_event.py
Outdated
Show resolved
Hide resolved
aws_lambda_powertools/utilities/data_classes/appsync_resolver_event.py
Outdated
Show resolved
Hide resolved
aws_lambda_powertools/utilities/data_classes/appsync_resolver_event.py
Outdated
Show resolved
Hide resolved
aws_lambda_powertools/utilities/data_classes/appsync_resolver_utils.py
Outdated
Show resolved
Hide resolved
app = AppSyncResolver() | ||
|
||
@app.resolver(field_name="createSomething", include_context=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this would be considered a Dataclass. I see two options:
- Discuss some design options in a RFC for lightweight API handling
- Expand Event Source Data Classes description to include utilities in it - Current description:
The event source data classes utility provides classes describing the schema of common Lambda events triggers.
The first is my preference as we might find other use cases, UX, as we put this into written form.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heitorlessa kind of started that here:
#324
But yes, in general having lightweight decorators help. Maybe like the SQS batch processing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's missing the RFC body like summary, drawbacks, alternatives, etc ;) one step a time
aws_lambda_powertools/utilities/data_classes/appsync_resolver_utils.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Heitor Lessa <[email protected]>
Co-authored-by: Heitor Lessa <[email protected]>
…solver_event.py Co-authored-by: Heitor Lessa <[email protected]>
I was thinking of leaving it as an undocumented or beta feature (but i will feature restructure the locations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some thought, let's leave it as-is AppSyncResolver()
and undocumented.
We can document that later once that RFC is written. That way, we add AppSync support within the data class, and have a good initial draft implementation of an AppSync Resolver ready to go once we find a better home for it.
To account for the utils()
bit in AppSync data class, please make those changes in the Event Source Data Classes top description to include utilities
too, so it doesn't get ruled out of scope for anything beyond a schema like this now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thank you!! I'll merge it as soon as the top text in the Data classes change to increase its scope to support utilities for event sources
app = AppSyncResolver() | ||
|
||
@app.resolver(field_name="createSomething", include_context=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's missing the RFC body like summary, drawbacks, alternatives, etc ;) one step a time
Description of changes:
Add support for AppSync Resolver Events either Direct or Amplify
Can also be used as a decorator
This is based on what Amplify produces by default:
Which is a simplification of is possible in the app sync $context :
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.