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

Query Batching? #52

Closed
adamjv90 opened this issue Feb 23, 2018 · 6 comments
Closed

Query Batching? #52

adamjv90 opened this issue Feb 23, 2018 · 6 comments

Comments

@adamjv90
Copy link

It looks like there is no way of supporting query batching since package.json doesn't include apollo-link-batch-http. Are there any plans to support this feature?

@RPDeshaies
Copy link

I don't really understand the point of using AppSync if it doesn't supports query batching. That's like one of the main benefit of using GraphQL

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

Hi @adamjv90 , @RPDeshaies

There are two similar concepts/approaches for this

  • "Query merging"
  • "Query batching" (transport level batching)

Query Batching is not yet part of the GraphQL standard/spec, the link you are referring to (apollo-link-batch-http) relies on server support for that implementation (apollo-server)

AWS AppSync definitively supports Query merging, e.g.

query {
  one: listEvents {
    items {
      name
    }
  }
  two: listEvents {
    items {
      description
    }
  }
}

@adamjv90
Copy link
Author

adamjv90 commented Apr 17, 2018

Thanks @manueliglesias the solution you propose would work however it would require you to program your application queries in a single query managed through a single container component (react scenario). It would be excellent if appsync could support query batching in a way that would allow a bunch of smaller components needing only a little bit of data each to all roll up into a single batched query to your backend thus improving the performance of your application.

Think of a list view where each row needed some data. Instead of having to code a list view container that would need to be responsible for figuring out which data its rows need, each row would be responsible for composing its own query and your application would batch up all the queries needed into a single request to your grapql server. This really seems like a very trivial problem that graphql and appsync should be able to solve.

You are right, the backend would need to support the implementation.. and really that is what would be really great for appsync to support.

@RPDeshaies
Copy link

@manueliglesias You are right. AppSync supports query merging, but as @adamjv90 described query batching is IMO way more efficient way of working and one of the great benefit of using an Appolo server VS AppSync.

Why close the issue? Because you are not going to implement it?

In that case, we might replace our Appsync server with a NodeJS lamda using Appolo concerning how much gain we might be able to get from query batching

@undefobj
Copy link
Contributor

@adamjv90 @RPDeshaies thanks for the feedback. We'll definitely add to our backlog. At this time as @manueliglesias said this is not part of the GraphQL specification and as an AWS service we need to be very careful about implementation for backwards compatibility reasons on future changes. Perhaps I could recommend opening up an issue on the GraphQL repo (https://github.com/facebook/graphql) for this to be adopted into the spec faster?

In the meantime, we have implemented a batch feature for DynamoDB resolvers which is spec compliant and highly scalable, which may or may not help with your use case: https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-dynamodb-batch.html

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.
@andrejunges
Copy link

@undefobj are there any updates about the support of batch operations? (something that'd work similar as apollo-link-batch-http)

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

No branches or pull requests

5 participants