I am trying to make a simple mutation to register a user. When I call .perform(mutation: GraphQLMutation), it works and a user is created in the database. I'm trying to now get information back from the server using the code below.
import Apollo
let userRegistrationInfo = RegisterMutation(email: email, name: fullName, username: username, uid: uid)
ApolloClass.shared.client.perform(mutation: userRegistrationInfo) { result in
print(result?.data?.register?.id)
}
When I only access and print result in my mutation call, this is the data I get back, so I know I'm getting something:
success(Apollo.GraphQLResult<JoinMi.RegisterMutation.Data>(data: Optional(JoinMi.RegisterMutation.Data(resultMap: ["register": Optional(["id": Optional("cjygbypjn59zt08668k7ktf6b"), "token": Optional("5jG6jbgb5dVy4ilrBLceKHCZmrS2"), "username": Optional(""), "name": Optional(""), "__typename": Optional("User")])])), errors: nil, source: Apollo.GraphQLResult<JoinMi.RegisterMutation.Data>.Source.server, dependentKeys: Optional(Set(["MUTATION_ROOT.register(email:helo@helo.com,name:,uid:5jG6jbgb5dVy4ilrBLceKHCZmrS2,username:).username", "MUTATION_ROOT.register(email:helo@helo.com,name:,uid:5jG6jbgb5dVy4ilrBLceKHCZmrS2,username:).name", "MUTATION_ROOT.register(email:helo@helo.com,name:,uid:5jG6jbgb5dVy4ilrBLceKHCZmrS2,username:).id", "MUTATION_ROOT.register(email:helo@helo.com,name:,uid:5jG6jbgb5dVy4ilrBLceKHCZmrS2,username:).__typename", "MUTATION_ROOT.register(email:helo@helo.com,name:,uid:5jG6jbgb5dVy4ilrBLceKHCZmrS2,username:)", "MUTATION_ROOT.register(email:helo@helo.com,name:,uid:5jG6jbgb5dVy4ilrBLceKHCZmrS2,username:).token"]))))
But when I try to access any of the data (e.g. result?.data?.register?.id) I get this error:
Generic parameter 'Mutation' could not be inferred
Here's my mutation:
mutation register($email: String!, $name: String, $username: String, $uid: String!) {
register(email: $email, name: $name, username: $username, uid: $uid) {
id
name
username
token
}
}
This is ApolloClass:
import Foundation
import Apollo
class ApolloClass {
static let shared = ApolloClass()
private(set) lazy var client = ApolloClient(url: URL(string: "...")!)
}
There has to be something I'm missing in the way I'm trying to access the contained data
I am trying to make a simple mutation to register a user. When I call
.perform(mutation: GraphQLMutation), it works and a user is created in the database. I'm trying to now get information back from the server using the code below.When I only access and print
resultin my mutation call, this is the data I get back, so I know I'm getting something:But when I try to access any of the data (e.g.
result?.data?.register?.id) I get this error:Here's my mutation:
This is ApolloClass:
There has to be something I'm missing in the way I'm trying to access the contained data