Skip to content

Commit 623b61d

Browse files
authored
[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
1 parent 4742d13 commit 623b61d

File tree

1 file changed

+4
-11
lines changed
  • src/pages/[platform]/build-a-backend/functions/set-up-function

1 file changed

+4
-11
lines changed

src/pages/[platform]/build-a-backend/functions/set-up-function/index.mdx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,20 +247,12 @@ safePrint(SayHelloResponse.sayHello.name);
247247

248248
```swift
249249
struct SayHelloResponse: Codable {
250-
public let sayHello: SayHello
251-
252-
struct SayHello: Codable {
253-
public let name: String
254-
public let executionDuration: Float
255-
}
250+
public let sayHello: String
256251
}
257252

258253
let document = """
259254
query EchoQuery($name: String!) {
260-
sayHello(name: $name) {
261-
name
262-
executionDuration
263-
}
255+
sayHello(name: $name)
264256
}
265257
"""
266258

@@ -269,7 +261,8 @@ let result = try await Amplify.API.query(request: GraphQLRequest<SayHelloRespons
269261
variables: [
270262
"name": "Amplify"
271263
],
272-
responseType: SayHelloResponse.self
264+
responseType: SayHelloResponse.self,
265+
authMode: AWSAuthorizationType.amazonCognitoUserPools
273266
))
274267
switch result {
275268
case .success(let response):

0 commit comments

Comments
 (0)