import { RxGraphQLReplicationClientState, RxGraphQLReplicationQueryBuilderResponseObject } from 'nxdb-old/src/types'; import { ensureNotFalsy } from 'nxdb-old/src/plugins/utils'; export const GRAPHQL_REPLICATION_PLUGIN_IDENTITY_PREFIX = 'graphql'; export interface GraphQLError { message: string; locations: Array<{ line: number; column: number; }>; path: string[]; } export type GraphQLErrors = Array; export function graphQLRequest( httpUrl: string, clientState: RxGraphQLReplicationClientState, queryParams: RxGraphQLReplicationQueryBuilderResponseObject ) { const headers = new Headers(clientState.headers || {}); headers.append('Content-Type', 'application/json'); const req = new Request( ensureNotFalsy(httpUrl), { method: 'POST', body: JSON.stringify(queryParams), headers, credentials: clientState.credentials, } ); return fetch(req) .then((res) => res.json()) .then((body) => { return body; }); }