Skip to content
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: add type branding to graphql in TS outputs #623

Merged
merged 9 commits into from
Aug 23, 2023

Conversation

svidgen
Copy link
Member

@svidgen svidgen commented Jul 12, 2023

Description of changes

In order to brand the generated graphql for TypeScript, we need to know the underlying operation type (Query | Mutation | Subscription) and specific operation name (CreateBlog, ListBlogs, etc.) at the time the graphql is formatted for the language output. This PR:

  1. Weaves op name and type through the statements map.
  2. Derives relative types import path from config.
  3. Conditionally adds types if the language is typescript.

Issue #, if available

Description of how you validated changes

  1. Updated snapshot for new TS output (tests pass)
  2. Ran through scenarios (To double-check functionality, these are combinations to replicate):
library codegen expected outcome
old old Base cases / no change
old new Base cases / no change
new new Base cases + API calls show specific arg and return types, preventing bad invocation
new old Base cases + allows custom typing of both arguments and result

Base cases

  1. Untyped graphql has generic typing — API category cannot infer or enforce specifics
  2. Overrides per the docs using GraphQLQuery and GraphQLSubscription wrappers provides return types

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)
  • Breaking changes to existing customers are released behind a feature flag or major version update
  • Changes are tested using sample applications for all relevant platforms (iOS/android/flutter/Javascript) that use the feature added/modified

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

@svidgen svidgen marked this pull request as ready for review August 3, 2023 17:18
@svidgen svidgen requested review from a team as code owners August 3, 2023 17:18
@svidgen svidgen changed the title wip: add types to graphql in TS outputs option 2 feat: add type branding to graphql in TS outputs Aug 3, 2023
@svidgen svidgen marked this pull request as draft August 3, 2023 17:50
@svidgen
Copy link
Member Author

svidgen commented Aug 3, 2023

Marking as draft again until PM's can review next Thursday. Happy to incorporate feedback between now and then though.

@svidgen svidgen marked this pull request as ready for review August 22, 2023 17:35
@svidgen svidgen merged commit b517ec3 into aws-amplify:main Aug 23, 2023
2 checks passed
@phani-srikar phani-srikar mentioned this pull request Aug 25, 2023
6 tasks
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