[WIP] Switched from rest to GraphQL #162-2
This commit is contained in:
@@ -1,28 +1,30 @@
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { HttpClient, HttpHeaders } from "@angular/common/http";
|
||||
import { Injectable } from "@angular/core";
|
||||
import { SettingsService } from "../settings/settings.service";
|
||||
import { Observable } from "rxjs";
|
||||
import { QueryResult } from "../../models/graphql/result.model";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: "root"
|
||||
})
|
||||
export class DataService {
|
||||
|
||||
// serverQuery = this.apollo.watchQuery({
|
||||
// query: gql`
|
||||
// {
|
||||
// serverCount
|
||||
// servers {
|
||||
// id
|
||||
// name
|
||||
// }
|
||||
// }
|
||||
// `
|
||||
// });
|
||||
|
||||
|
||||
constructor(
|
||||
private appsettings: SettingsService,
|
||||
private http: HttpClient
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
query(query: string, variables: object = {}): Observable<QueryResult> {
|
||||
return this.http.post<QueryResult>(`${this.appsettings.getApiURL()}/api/graphql`,
|
||||
JSON.stringify({
|
||||
query, variables
|
||||
}), {
|
||||
headers: new HttpHeaders({
|
||||
"Content-Type": "application/json"
|
||||
})
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user