From 623b61d55eaf4524580c901e24f025322f3ab45b Mon Sep 17 00:00:00 2001 From: lightboys22 Date: Sun, 5 Oct 2025 17:20:44 -0700 Subject: [PATCH] [Gen 2][Swift][Fix doc example] Do not merge. I want to report bug on the Swift example on creating a Lambda function Do not merge this change. I just want to report bug on the Swift example on creating a Lambda function. If we don't have the "authMode: AWSAuthorizationType.amazonCognitoUserPools" change, I will get the following run time error when my Swift app make the GraphQL request: ``` "Not Authorized to access sayHello on type Query" ``` Regarding the following change, ... ``` struct SayHelloResponse: Codable { public let sayHello: String } struct PushNotifyRequest { private static let document = """ query EchoQuery($name: String!) { sayHello(name: $name) } """ ``` Since the "sayHello" only returns a String, a String struct doesn't have properties, such as "name" or "executionDuration". So I remove those two properties. I only know how to fix the Swift example. I haven't fix the example for other platforms. Below is the document I would like to fix. https://github.com/aws-amplify/docs/blob/main/src/pages/%5Bplatform%5D/build-a-backend/functions/set-up-function/index.mdx --- .../functions/set-up-function/index.mdx | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/pages/[platform]/build-a-backend/functions/set-up-function/index.mdx b/src/pages/[platform]/build-a-backend/functions/set-up-function/index.mdx index acb8f4b331f..932f2c80be4 100644 --- a/src/pages/[platform]/build-a-backend/functions/set-up-function/index.mdx +++ b/src/pages/[platform]/build-a-backend/functions/set-up-function/index.mdx @@ -247,20 +247,12 @@ safePrint(SayHelloResponse.sayHello.name); ```swift struct SayHelloResponse: Codable { - public let sayHello: SayHello - - struct SayHello: Codable { - public let name: String - public let executionDuration: Float - } + public let sayHello: String } let document = """ query EchoQuery($name: String!) { - sayHello(name: $name) { - name - executionDuration - } + sayHello(name: $name) } """ @@ -269,7 +261,8 @@ let result = try await Amplify.API.query(request: GraphQLRequest