New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using HttpLink from apollo-angular-link-http #263
Comments
Hi @fcobia
Something like this might work: const apolloHttpLink = httpLink.create({uri: env.endpoint}); // from apollo-angular-link-http
const appSyncLink = createAppSyncLink({
url: env.endpoint,
region: appSyncConfig.region,
auth: {
type: appSyncConfig.authenticationType,
apiKey: appSyncConfig.apiKey
},
resultsFetcherLink: apolloHttpLink
});
const client = new AWSAppSyncClient({
disableOffline: true
}, { link , ssrMode: true}); Can you try it and let us know how it goes? |
@manueliglesias Also, and this may be completely unrelated to this code, but when I use this code I started getting 'Refused to set unsafe header "host"' errors in the console whenever a GraphQL call is made. Do you know why this is happening?
|
@fcobia hey, did you come to a conclusion about why the error appears in the console? I have done the same stuff you did, and can not seem to be able to get rid of the error :(. |
It has been a while and I don't remember. I am sure I must have because the project does work now. However, I don't remember what I did. |
@fcobia no problem, thanks anyway. However, I am trying to get rid of |
I am creating an Angular 6 app and I am trying to get server side rendering working. I am having a lot of trouble with getting the page to wait for the GraphQL calls to AppSync to finish before the page is rendered.
I suspected that the calls were being made outside the zone.js framework and so Angular could not detect when the calls were finished. And finally today I came across this which under the section titled "Server-side rendering" says that you must use HttpLink from apollo-angular-link-http for GraphQL to work correctly with zone.js.
So I looked at the source to aws-appsync and this issue to configure the AWSAppsyncClient to use the HttpLink from apollo-angular-link-http. See the code below.
However, this causes the GraphQL calls to fail. When I try in a web browser I simply get the following error and there is no call to app sync listed in the network tab of the Chrome browser:
When I run the server side code it give the same error but it shows a stack trace that gives a little more information. Down in the stack trace it has:
How can I configure the AWSAppSyncClient to use the HttpLink so that zones works correctly?
Here is the code I use to create the AWSAppSync Client with the creation code that works (minus zones) commented out. Please excuse the messy code. I have been doing a lot of experimenting.
The text was updated successfully, but these errors were encountered: