mirror of
https://github.com/chuot/rdio-scanner.git
synced 2026-08-13 16:33:01 -06:00
Fix graphql base uri
This commit is contained in:
parent
a2eb2005de
commit
2402ee5e15
|
|
@ -1,33 +1,37 @@
|
|||
import { HttpClientModule } from '@angular/common/http';
|
||||
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 { InMemoryCache } from 'apollo-cache-inmemory';
|
||||
import { split } from 'apollo-link';
|
||||
import { WebSocketLink } from 'apollo-link-ws';
|
||||
import { getMainDefinition } from 'apollo-utilities';
|
||||
|
||||
export const httpLinkFactory = (httpLink: HttpLink) => ({
|
||||
cache: new InMemoryCache(),
|
||||
link: split(
|
||||
({ query }) => {
|
||||
const def = getMainDefinition(query);
|
||||
export const httpLinkFactory = (httpLink: HttpLink) => {
|
||||
const href = window.location.href.endsWith('/') ? window.location.href : window.location.href + '/';
|
||||
|
||||
return def.kind === 'OperationDefinition' && def.operation === 'subscription';
|
||||
},
|
||||
return {
|
||||
cache: new InMemoryCache(),
|
||||
link: split(
|
||||
({ query }) => {
|
||||
const def = getMainDefinition(query);
|
||||
|
||||
new WebSocketLink({
|
||||
options: {
|
||||
reconnect: true,
|
||||
return def.kind === 'OperationDefinition' && def.operation === 'subscription';
|
||||
},
|
||||
uri: window.location.href.replace(/^http/, 'ws') + 'graphql',
|
||||
}),
|
||||
|
||||
httpLink.create({
|
||||
uri: window.location.href + 'graphql',
|
||||
}),
|
||||
),
|
||||
});
|
||||
new WebSocketLink({
|
||||
options: {
|
||||
reconnect: true,
|
||||
},
|
||||
uri: href.replace(/^http/, 'ws') + 'graphql',
|
||||
}),
|
||||
|
||||
httpLink.create({
|
||||
uri: href + 'graphql',
|
||||
}),
|
||||
),
|
||||
};
|
||||
};
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
|
|
|||
Loading…
Reference in a new issue