You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import {NgModule} from '@angular/core';
import {APOLLO_OPTIONS} from 'apollo-angular';
import {ApolloClientOptions, InMemoryCache} from '@apollo/client/core';
import {HttpLink} from 'apollo-angular/http';
import {environment} from "../environments/environment";
import {HttpClientModule} from "@angular/common/http";
import {BrowserModule} from "@angular/platform-browser";
const uri = environment.BLOG_URL+'/graphql'; // <-- add the URL of the GraphQL server here
export function createApollo(httpLink: HttpLink): ApolloClientOptions {
return {
link: httpLink.create({uri}),
cache: new InMemoryCache(),
ssrMode: true,
ssrForceFetchDelay: 1000,
};
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
We are having struggles with this error. When we refresh on page and renders it with SSR. graphql gives an error on Node.
The error is the next:
|main | ERROR ApolloError: undefined 8|main | at new ApolloError (/var/www/html/server/main.js:1:1260333) 8|main | at /var/www/html/server/main.js:18:2250540 8|main | at /var/www/html/server/main.js:47:1011502 8|main | at new ZoneAwarePromise (/var/www/html/server/main.js:18:2431986) 8|main | at Object.error (/var/www/html/server/main.js:47:1011456) 8|main | at notifySubscription (/var/www/html/server/main.js:47:870249) 8|main | at onNotify (/var/www/html/server/main.js:47:871052) 8|main | at SubscriptionObserver.error (/var/www/html/server/main.js:47:872109) 8|main | at /var/www/html/server/main.js:47:1008127 8|main | at Array.forEach (<anonymous>) { 8|main | graphQLErrors: [], 8|main | networkError: 'Unknown Error', 8|main | message: 'undefined', 8|main | extraInfo: undefined
Also we are debugged and can see this:
status: 0, 8|main | statusText: 'Unknown Error', 8|main | url: 'https://blog.XXX.com/graphql', 8|main | ok: false, 8|main | name: 'HttpErrorResponse', 8|main | message: 'Http failure response for https://blog.XXX.com/graphql: 0 Unknown Error', 8|main | error: ProgressEvent { 8|main | type: 'error', 8|main | target: XMLHttpRequest { 8|main | onloadstart: null, 8|main | onprogress: null, 8|main | onabort: null, 8|main | onerror: null, 8|main | onload: null, 8|main | ontimeout: null, 8|main | onloadend: null, 8|main | _listeners: [Object], 8|main | onreadystatechange: null, 8|main | _anonymous: undefined, 8|main | readyState: 4, 8|main | response: null, 8|main | responseText: '', 8|main | responseType: 'text', 8|main | responseURL: '', 8|main | status: 0, 8|main | statusText: '', 8|main | timeout: 0, 8|main | upload: [XMLHttpRequestUpload], 8|main | _method: 'POST',
My graphql.module.ts
import {NgModule} from '@angular/core';
import {APOLLO_OPTIONS} from 'apollo-angular';
import {ApolloClientOptions, InMemoryCache} from '@apollo/client/core';
import {HttpLink} from 'apollo-angular/http';
import {environment} from "../environments/environment";
import {HttpClientModule} from "@angular/common/http";
import {BrowserModule} from "@angular/platform-browser";
const uri = environment.BLOG_URL+'/graphql'; // <-- add the URL of the GraphQL server here
export function createApollo(httpLink: HttpLink): ApolloClientOptions {
return {
link: httpLink.create({uri}),
cache: new InMemoryCache(),
ssrMode: true,
ssrForceFetchDelay: 1000,
};
}
@NgModule({
imports: [
// ...
HttpClientModule,
],
providers: [
{
provide: APOLLO_OPTIONS,
useFactory: createApollo,
deps: [HttpLink],
},
],
})
export class GraphQLModule {}
Thank you
PD: Also when we execute the same build on local, it works.. It happens on PROD
Beta Was this translation helpful? Give feedback.
All reactions