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
How can I add a custom link to the link chain? #3
Comments
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 aws-mobile-appsync-sdk-js/packages/aws-appsync/src/client.js Lines 102 to 120 in 87c52f4
|
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) |
Allows the usage of: - Custom link - Custom cache - Custom cache options Fixes awslabs#3 Fixes awslabs#21 Fixes awslabs#24 Fixes awslabs#36 Fixes awslabs#52 Fixes awslabs#70 Fixes awslabs#87 Closes awslabs#62
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 }); |
* Use custom link cache and cache options Allows the usage of: - Custom link - Custom cache - Custom cache options Fixes #3 Fixes #21 Fixes #24 Fixes #36 Fixes #52 Fixes #70 Fixes #87 Closes #62 * Pass store to OfflineLink when using createAppSyncLink * Fix eslint rules violations * Fix typo. Address CR comment.
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
The text was updated successfully, but these errors were encountered: