-
Notifications
You must be signed in to change notification settings - Fork 203
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
[Feedback]Make a GraphQL request for a nested query #663
Comments
Thanks for clarifying the request @swaminator. To add another (very related) query: By using custom queries I'm wanting to fetch nested objects with a single HTTP request but also wanting to avoid over-fetching of data by allowing engineers on the client side to specify which subset of fields they require. Thanks! |
Hi @mrtom, we have some ideas to provide a migration strategy for customers using AppSync SDK to Amplify API plugin. It may involve exensions that translate the code generated classes in AppSync over to the Amplify's |
I believe a custom query where you pass a custom selection set is the first step to getting a subset of fields required on the client side. Are you constructing a Then what is the |
I had imagined that a code gen step could/would be run that would generate models for a specific query, but in a strongly typed language like Swift it can be difficult to do well. There are three approaches that I feel you could consider. Let's imagine you have a GraphQL schema like so, with a user and a post, and a many-to-many connection between users and posts.
You may want to get a list of posts by created date or whatever and just render the the authors name next to each post. So you may create a GraphQL query like (haven't created this IRL, so may not be perfect):
So here, you have a query that gets all the fields for the Post type, but only one field (the username) for the associated users. I think you have three options:
You could also add some linting/static analysis to ensure that only fields which have been fetched are accessed. Relay does this for example, but requires adding fragments for each component. This doesn't work very well with UIKits programming model, but would work very well with SwiftUI. |
Hello, We have an example to create custom GraphQL requests for nested data queries through the custom selection set feature. Let us know if this works for you. |
@thisisabhash - How would this look for TypeScript/JavaScript? I've been after this for so, so long! |
@armenr Please open an issue in the JS repo with your question: https://github.com/aws-amplify/amplify-js |
I'm good. I figured it out myself. Thanks for the quick instructions to open issues. |
Page:
/lib/q/platform/ios
Feedback:
Hi there!
I'm trying to update a fairly straightforward app from the old Amplify SDK to the new Amplify Library. The docs don't have any migration guide sadly.
One thing that isn't at all clear is how you go about using custom queries with the API exposed by the library. The docs show how to fetch a single or list of a model, but not how to make a GraphQL request for, say, a nested query.
Please could you advise?
Many thanks!
The text was updated successfully, but these errors were encountered: