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 angular codegen v6 support #799

Merged
merged 9 commits into from
Apr 3, 2024
Merged

feat: add angular codegen v6 support #799

merged 9 commits into from
Apr 3, 2024

Conversation

AaronZyLee
Copy link
Contributor

@AaronZyLee AaronZyLee commented Mar 19, 2024

Description of changes

Added angular codegen support for JS V6

The new users will have the amplifyJsLibraryVersion with default value as 6 in their .graphqlconfig.yml file when running amplify codegen add and selecting the angular target.

The old v5 angular users are not impacted as the config file is not modified. To opt-in the new codegen, they can run amplify codegen remove and amplify codegen add with the same angular option as target.

The old v5 angular is still available by editing the .graphqlconfig.yml file to switch the amplifyJsLibraryVersion from 6 to 5.

The other inputs in this field are invalid with warning message and will fall into the v6 codegen behavior.

Changes for angular codegen v6 include:

  • New import for aws-amplify/api and rxjs
import { Injectable } from "@angular/core";
import { Client, generateClient, GraphQLResult } from "aws-amplify/api";
import { Observable } from "rxjs";
  • Queries, mutations and subscriptions use the generateClient to execute APIs
export class APIService {
  public client: Client;
  constructor() {
    this.client = generateClient();
  }

  async GetTodo(id: string): Promise<GetTodoQuery> {
    //...
    const response = (await this.client.graphql({
      query: statement,
      variables: gqlAPIServiceArguments
    })) as any;
    return <GetTodoQuery>response.data.getTodo;
  }

  async CreateTodo(
    input: CreateTodoInput,
    condition?: ModelTodoConditionInput
  ): Promise<CreateTodoMutation> {
    //...
    const response = (await this.client.graphql({
      query: statement,
      variables: gqlAPIServiceArguments
    })) as any;
    return <CreateTodoMutation>response.data.createTodo;
  }

  OnCreateTodoListener(
    filter?: ModelSubscriptionTodoFilterInput
  ): Observable<GraphQLResult<Pick<__SubscriptionContainer, "onCreateTodo">>> {
    //...
    return this.client.graphql({
      query: statement,
      variables: gqlAPIServiceArguments
    }) as any;
  }
}

Codegen Paramaters Changed or Added

New target angularv6 in typegen

Issue #, if available

Fix #783

Description of how you validated changes

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
  • Changes are tested on windows. Some Node functions (such as path) behave differently on windows.

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

@AaronZyLee AaronZyLee requested a review from a team as a code owner March 19, 2024 23:33
@AaronZyLee AaronZyLee marked this pull request as draft March 19, 2024 23:33
@AaronZyLee AaronZyLee marked this pull request as ready for review March 20, 2024 23:24
@AaronZyLee AaronZyLee requested a review from a team as a code owner March 20, 2024 23:24
Copy link
Contributor

@phani-srikar phani-srikar left a comment

Choose a reason for hiding this comment

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

We previously had tests for when this new config property is undefined and we added unit tests for V6, can you also add a test when it's set to v5?

@AaronZyLee AaronZyLee enabled auto-merge (squash) March 31, 2024 20:56
@elaf2001
Copy link

elaf2001 commented Apr 2, 2024

Could you provide an estimate on when the team plans to review and potentially merge this code? It would be helpful for those of us interested in the feature to have an idea of the timeline. Thank you!

Copy link
Member

@iartemiev iartemiev left a comment

Choose a reason for hiding this comment

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

Giving admin approval for API.md changes, did not review the rest of the PR

@AaronZyLee AaronZyLee merged commit 7d1a269 into main Apr 3, 2024
4 checks passed
@AaronZyLee AaronZyLee deleted the fix-angular branch April 3, 2024 17:35
@dpilch dpilch mentioned this pull request Apr 3, 2024
2 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.

Angular code generation for v6 amplify
5 participants