Skip to content
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

Fragments on unions and interfaces #70

Closed
alexeygolev opened this issue Mar 12, 2018 · 4 comments
Closed

Fragments on unions and interfaces #70

alexeygolev opened this issue Mar 12, 2018 · 4 comments
Labels
bug Used as a label for bugs found in AppSync SDK question Ask us a question

Comments

@alexeygolev
Copy link
Contributor

alexeygolev commented Mar 12, 2018

There is no way to use union type or interfaces with the current client implementation as apollo requires an instance of IntrospectionFragmentMatcher passed into the InMemoryCache and there is no way to hook into the instantiation of the client at the moment.
First, I assumed that #3 might be the way to go. Yet it's not about additional links, we actually need to provide the fragmentMatcher for InMemoryCache here:

const cache = new InMemoryCache(store);

@alexeygolev
Copy link
Contributor Author

As far as I can understand both cache implementations use InMemory as a base class, so the fragment matcher logic is untouched. Maybe we could pass the fragmentMatcher with the constructor argument?

@jpstrikesback
Copy link

We're doing this via #62 by passing in a set of links and cache

@jpstrikesback
Copy link

(the link(s) depend on a cache implementation, and it should be a singleton afaik)

@nidsharm nidsharm added bug Used as a label for bugs found in AppSync SDK question Ask us a question labels Apr 10, 2018
manueliglesias added a commit to manueliglesias/aws-mobile-appsync-sdk-js that referenced this issue Apr 16, 2018
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
@manueliglesias
Copy link
Contributor

Once PR #96 gets merged, it should be possible to pass custom cache options to the AWS AppSync client like this:

import AWSAppSyncClient from "aws-appsync";

const client = new AWSAppSyncClient({
  url: appSyncConfig.graphqlEndpoint,
  region: appSyncConfig.region,
  auth: {
    type: appSyncConfig.authenticationType,
    apiKey: appSyncConfig.apiKey
  },
  cacheOptions: {
    dataIdFromObject: obj => obj.__typename && obj.id && `MyPrefix:${obj.__typename}:${obj.id}`
  }
});

manueliglesias added a commit that referenced this issue Apr 19, 2018
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used as a label for bugs found in AppSync SDK question Ask us a question
Projects
None yet
Development

No branches or pull requests

4 participants