Angular Graphql Codegen - Mutate issue

Discussão em 'Angular' iniciado por DanyBoy, Outubro 8, 2024.

  1. DanyBoy

    DanyBoy Guest

    I'm currently facing an issue when I try to execute this simple mutation via GraphqlCodegen / Angular:

    ERROR TypeError: Cannot read properties of undefined (reading 'mutate')
    at _LoginService.signIn (login.service.ts:15:20)
    at _LoginComponent.onSubmit (login.component.ts:37:23)
    at LoginComponent_Template_button_click_30_listener (login.component.html:86:22)
    at executeListenerWithErrorHandling (core.mjs:24697:16)
    at wrapListenerIn_markDirtyAndPreventDefault (core.mjs:24730:22)
    at HTMLButtonElement.<anonymous> (platform-browser.mjs:749:112)
    at _ZoneDelegate.invokeTask (zone.js:402:31)
    at core.mjs:14452:55
    at AsyncStackTaggingZoneSpec.onInvokeTask (core.mjs:14452:36)
    at _ZoneDelegate.invokeTask (zone.js:401:60)
    Many thanks for your help


    import { Injectable } from '@angular/core';
    import { signInMutationService } from '../../../graphql/generated';

    @Injectable({
    providedIn: 'root',
    })
    export class LoginService {
    //private readonly JWT_TOKEN = 'JWT_TOKEN';
    //private loggedUser?: string;
    //private isAuthenticatedSubject = new BehaviorSubject<boolean>(false);
    private signInGQL: signInMutationService

    signIn(login: string, password: string) {

    this.signInGQL.mutate({
    authInput: {
    login,
    password
    }
    }).subscribe(({ data, errors, loading }) => {
    if (errors) {
    console.error('Error getting connection', errors);
    }
    if (data) {
    console.log('Data retrieved', JSON.stringify(data, null, 2));
    }
    })
    }

    }


    First, I don't really understand the meaning of this issue and how to fix it

    THanks in advance for your precious help

    Continue reading...

Compartilhe esta Página