I have been struggling with an issue involving Apollo mutation for the past 2 days.
Whenever I call a mutation on Angular Apollo generated code and subscribe to it, the subscription never completes. I am expecting a result from the server, but nothing is being returned.
I'm not sure why it's not completing. Interestingly, when I directly call the GraphQL server with a POST request using Postman, I do get the expected result.
constructor(
private createAccount: CreateAccountGQL,) {
}
ngOnInit() {
this.createAccount.mutate({
data: {
uid: 'sdfsdfsdfs',
username: 'yxydfsdsdsdfsfsfsd',
},
}).subscribe(result => {
// THIS CODE NEVER EXECUTES
console.log(result)
});
}
Below is the generated code:
@Injectable({
providedIn: "root"
})
export class CreateAccountGQL extends Apollo.Mutation<
CreateAccountMutation,
CreateAccountVariables
> {
document: any = gql`
mutation createAccount($data: AccountCreateInput!) {
createAccount(data: $data) {
id
username
uid
}
}
`;
}
I am eager to receive some help in ensuring my subscribe complete callback works as intended. Thank you.