### File

`projects/commons/src/lib/core/gql/services/gql.service.ts`

### Index

###### Methods
Public mutate Public watchQuery

### Constructor

`constructor(apollo: Apollo)`
Defined in projects/commons/src/lib/core/gql/services/gql.service.ts:7
Parameters :
Name | Type | Optional
apollo | `Apollo` | No

### Methods

Public mutate
`mutate(undefined)`
Defined in projects/commons/src/lib/core/gql/services/gql.service.ts:21
Parameters :
Name | Optional
No
Returns : `Observable<any>`

Public watchQuery
`watchQuery(undefined)`
Defined in projects/commons/src/lib/core/gql/services/gql.service.ts:10
Parameters :
Name | Optional
No
Returns : `Observable<any>`

    import { Observable } from 'rxjs';
    import { Apollo } from 'apollo-angular';
    import { Injectable } from '@angular/core';
    import { map } from 'rxjs/operators';

    @Injectable()
    export class GqlService {
        constructor(private readonly apollo: Apollo) {}

        public watchQuery({ query }): Observable<any> {
            return this.apollo.watchQuery({
                query,
                fetchPolicy: 'network-only'
            }).valueChanges.pipe(map(({ data }) => {
                const key = Object.keys(data)[0];

                return data[key];
            }));
        }

        public mutate({ mutation, variables }): Observable<any> {
            return this.apollo.mutate({ mutation, variables });
        }
    }

# result-matching ""

# No results matching ""