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

allow users to pass link compositions and custom caches #62

Closed
wants to merge 3 commits into from

Conversation

jpstrikesback
Copy link

We need to be able to pass in our own links along with the lovely links from AWS.

Likewise for an Apollo cache (especially since we want to use the same cache we use for the client in say apollo-link-state, cause that's what I was told to do)

This should help with: #52 #36 #24 #21 #3

Let me know if this looks good, interesting, undesirable, or needs work.

Cheers,
JP

@alexeygolev
Copy link
Contributor

This is really needed as unions and interfaces are pretty much useless with apollo without a fragmentMatcher which can't be provided at the moment

const cache = disableOffline ? new InMemoryCache() : new OfflineCache(store);

const cache = disableOffline
? ownCache ? owncache : new InMemoryCache()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assignment would be cleaner if you swap the ternary operators:

const cache = ownCache ? ownCache
    : disableOffline ? new InMemoryCache()
    : new OfflineCache(store);

There also seems to be a typo on line 56: owncache should be ownCache.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed with this feedback as it is a lot more readable.

@dguisinger
Copy link
Contributor

I think there should be a way to add links without having to redefine the AWS links. I don't want to have to manually keep track of AWS internal SDK changes in order to get all of the out-of-the-box functionality when supplying a custom link. Maybe a function that can return an array of the AWS supplied links that can be used in the following way:
[ myLink, ...AwsAppSyncDefaultLinks() ]

in my case, I'm looking to use a link to stripout __typename properties on objects submitted to mutations, not override any AWS provided functionality.

manueliglesias added a commit to manueliglesias/aws-mobile-appsync-sdk-js that referenced this pull request 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

Hey

This should be possible soon, take a look at #96 and these comments with usage examples:

manueliglesias added a commit that referenced this pull request 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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants