here my code in swift:
mutation = LoginMutation( email: "[email protected]",password: "pa$$w0rd")
ApolloManager.shared.apollo.perform(mutation: mutation, resultHandler: { result in
switch result {
case .success(let graphQLResult):
if let data = graphQLResult.data {
print("Token: \(data)")
} else if let errors = graphQLResult.errors {
print(errors)
}
case .failure(let error):
print(error)
}
})
I get an error in the generated file and here is the error
Instance method 'perform(mutation:publishResultToStore:context:queue:resultHandler:)' requires that 'LoginMutation' conform to 'GraphQLMutation'
btw I used pod file to add some references as I followed the documentation. here is in my podfile:
# platform :ios, '9.0'
target 'ProjectName' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for AhenteNew
pod 'Apollo'
pod 'Apollo/SQLite'
pod 'Apollo/WebSocket'
end
I used apollo-ios-cli to generate my API but I'm not sure why it is not running. if I made the project using the podfile the error showed while using the package dependencies the program worked fine. I don't know why the error saying cannot conform. please give the solution for this.
PS: here is my code in apollo-codegen-config
{
"schemaNamespace" : "ProjectAPI",
"input" : {
"operationSearchPaths" : [
"**/*.graphql"
],
"schemaSearchPaths" : [
"**/*.graphqls"
]
},
"output" : {
"testMocks" : {
"none" : {
}
},
"schemaTypes" : {
"path" : "./ProjectAPI",
"moduleType" : {
"swiftPackageManager" : {
}
}
},
"operations" : {
"inSchemaModule" : {
}
}
},
"schemaDownloadConfiguration": {
"downloadMethod": {
"introspection": {
"endpointURL": "<myendpoint>",
"httpMethod": {
"POST": {}
},
"includeDeprecatedInputValues": false,
"outputFormat": "SDL"
}
},
"downloadTimeout": 60,
"headers": [],
"outputPath": "./ProjectName/graphql/schema.graphqls"
}
}
using terminal I used these code:
(base) <dir> % ./apollo-ios-cli fetch-schema
(base) <dir> % ./apollo-ios-cli generate
any answer will be appreciated.