mirror of
https://github.com/chuot/rdio-scanner.git
synced 2026-08-16 09:53:01 -06:00
Fix graphql base uri
This commit is contained in:
parent
a2eb2005de
commit
2402ee5e15
|
|
@ -1,13 +1,16 @@
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
import { ModuleWithProviders, NgModule } from '@angular/core';
|
import { ModuleWithProviders, NgModule } from '@angular/core';
|
||||||
import { APOLLO_OPTIONS, ApolloModule } from 'apollo-angular';
|
import { ApolloModule, APOLLO_OPTIONS } from 'apollo-angular';
|
||||||
import { HttpLink, HttpLinkModule } from 'apollo-angular-link-http';
|
import { HttpLink, HttpLinkModule } from 'apollo-angular-link-http';
|
||||||
import { InMemoryCache } from 'apollo-cache-inmemory';
|
import { InMemoryCache } from 'apollo-cache-inmemory';
|
||||||
import { split } from 'apollo-link';
|
import { split } from 'apollo-link';
|
||||||
import { WebSocketLink } from 'apollo-link-ws';
|
import { WebSocketLink } from 'apollo-link-ws';
|
||||||
import { getMainDefinition } from 'apollo-utilities';
|
import { getMainDefinition } from 'apollo-utilities';
|
||||||
|
|
||||||
export const httpLinkFactory = (httpLink: HttpLink) => ({
|
export const httpLinkFactory = (httpLink: HttpLink) => {
|
||||||
|
const href = window.location.href.endsWith('/') ? window.location.href : window.location.href + '/';
|
||||||
|
|
||||||
|
return {
|
||||||
cache: new InMemoryCache(),
|
cache: new InMemoryCache(),
|
||||||
link: split(
|
link: split(
|
||||||
({ query }) => {
|
({ query }) => {
|
||||||
|
|
@ -20,14 +23,15 @@ export const httpLinkFactory = (httpLink: HttpLink) => ({
|
||||||
options: {
|
options: {
|
||||||
reconnect: true,
|
reconnect: true,
|
||||||
},
|
},
|
||||||
uri: window.location.href.replace(/^http/, 'ws') + 'graphql',
|
uri: href.replace(/^http/, 'ws') + 'graphql',
|
||||||
}),
|
}),
|
||||||
|
|
||||||
httpLink.create({
|
httpLink.create({
|
||||||
uri: window.location.href + 'graphql',
|
uri: href + 'graphql',
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
});
|
};
|
||||||
|
};
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue