How would I extend the link chain with a link such as apollo-link-error?
https://github.com/apollographql/apollo-link/tree/master/packages/apollo-link-error
Hi @kabriel
Thanks for trying the service and the sdk!
As of now, it is not possible to customize the link chain. We're looking into supporting it, stay tuned.
For now, you can use a vanilla apollo-client instance with this package's links https://github.com/awslabs/aws-mobile-appsync-sdk-js/blob/87c52f48af957f21d335d1e53111d68479b41e38/packages/aws-appsync/src/client.js#L102-L120
Hey there, just want to chime in to mention that we'd like to use apollo-link-state for local state, and potentially try a different cache implementation like apollo-hermes-cache.
We're currently doing this now via the PR #62, usage (i.e. using the fork via npm/yarn link) is rather difficult mind you if your bundler isn't fond of symlinks (metro seems to choke on them)
Once PR #96 gets merged, it should be possible to use custom links with the AWS AppSync client like this: (e.g. apollo-link-error)
import { ApolloLink } from 'apollo-link';
import { onError } from 'apollo-link-error';
import AWSAppSyncClient, { createAppSyncLink } from "aws-appsync";
const onErrorLink = onError(({ graphQLErrors, networkError }) => {
if (graphQLErrors)
graphQLErrors.map(({ message, locations, path }) =>
console.log(
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
)
);
if (networkError) console.log(`[Network error]: ${networkError}`);
});
const appSyncLink = createAppSyncLink({
url: appSyncConfig.graphqlEndpoint,
region: appSyncConfig.region,
auth: {
type: appSyncConfig.authenticationType,
apiKey: appSyncConfig.apiKey
}
});
const link = ApolloLink.from([
onErrorLink,
appSyncLink
]);
const client = new AWSAppSyncClient({}, { link });
Most helpful comment
Once PR #96 gets merged, it should be possible to use custom links with the AWS AppSync client like this: (e.g. apollo-link-error)