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(api): add authorizationMode to GraphQLRequest #3630

Merged
merged 6 commits into from
Apr 26, 2024
Merged

Conversation

lawmicha
Copy link
Contributor

@lawmicha lawmicha commented Apr 23, 2024

Issue #

Description

This PR adds the ability to specify the authorization mode when making a GraphQLRequest. AppSync specific authorization modes are defined as AWSAuthorizationType in AWSPluginsCore. This a public interface from the "AWS" specific packages.

API Changes

Using GraphQLRequest builders

import Amplify
import AWSPluginsCore

try await Amplify.API.mutate(request: .create(model, authMode: .apiKey))

try await Amplify.API.mutate(request: .update(model, authMode: .apiKey))

try await Amplify.API.mutate(request: .delete(model, authMode: .apiKey))

try await Amplify.API.query(request: .query(Model.self, byIdentifier: model.identifier, authMode: .apiKey))

try await Amplify.API.query(request: .list(Model.self, authMode: .apiKey))

try await Amplify.API.subscribe(request: .onCreate(Model.self, authMode: .apiKey))

try await Amplify.API.subscribe(request: .onUpdate(Model.self, authMode: .apiKey))

try await Amplify.API.subscribe(request: .onDelete(Model.self, authMode: .apiKey))

Adding authMode parameter for all GraphQLRequest builders.

Using GraphQLRequest directly

import Amplify
import AWSPluginsCore

let request = GraphQLRequest<JSONValue>(
    apiName: apiName,
    document: documentString,
    variables: ["id": "id123"],
    responseType: JSONValue.self,
    authorizationMode: AWSAuthorizationType.apiKey)

General Checklist

  • Added new tests to cover change, if needed
  • Build succeeds with all target using Swift Package Manager
  • All unit tests pass
  • All integration tests pass
  • Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)
  • Documentation update for the change if required
  • PR title conforms to conventional commit style
  • New or updated tests include Given When Then inline code documentation and are named accordingly testThing_condition_expectation()
  • If breaking change, documentation/changelog update with migration instructions

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

@lawmicha lawmicha requested a review from a team as a code owner April 23, 2024 21:54
5d
5d previously approved these changes Apr 25, 2024
5d
5d previously approved these changes Apr 25, 2024
5d
5d previously approved these changes Apr 25, 2024
…reddata/xcschemes/AWSAPIPluginGen2LazyLoadTests.xcscheme
@lawmicha lawmicha merged commit 3ffde2b into main Apr 26, 2024
79 checks passed
@lawmicha lawmicha deleted the feat.auth-type-2 branch April 26, 2024 04:40
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.

2 participants