-
Notifications
You must be signed in to change notification settings - Fork 247
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
feat(amplify_api): GraphQL Query Helper - List #771
feat(amplify_api): GraphQL Query Helper - List #771
Conversation
Codecov Report
@@ Coverage Diff @@
## feature/graphql_helpers #771 +/- ##
===========================================================
+ Coverage 69.52% 69.59% +0.07%
===========================================================
Files 269 271 +2
Lines 8921 8950 +29
Branches 361 361
===========================================================
+ Hits 6202 6229 +27
- Misses 2587 2589 +2
Partials 132 132
Flags with carried forward coverage won't be shown. Click here to find out more.
|
packages/amplify_api/lib/src/graphql/paginated_modelType_impl.dart
Outdated
Show resolved
Hide resolved
packages/amplify_api/lib/src/graphql/paginated_modelType_impl.dart
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking pretty snazzy! 😄
General comments:
- Let's make all constructors
const
and fieldsfinal
when possible (a good rule of thumb)
I'm also going to recommend changing gears a bit and removing documentArgs
from the document build step. Ideally, when building the document, we just look at the schema to see what it accepts for input. We're constructing a generic document, essentially, which can be used for any set of variable values (and this will help with caching later, too). The values for those inputs are passed separately in the GraphQL request, and then the server looks at both to do validation and build the actual query.
Example
A user requests a listTodo
operation.
Schema:
type Todo @model {
id: ID!
title: String!
description: String
}
type Query {
listTodos(filter: ModelTodoFilterInput, limit: Int, nextToken: String): ModelTodoConnection
}
Document we build:
query listTodos($filter: ModelTodoFilterInput, $limit: Int, $nextToken: String) {
listTodos(filter: $filter, limit: $limit, nextToken: $nextToken) {
nextToken
items {
id
title
description
}
}
}
Variables (JSON) - nullable variables can be omitted or included as null
:
{
"limit": 100,
"nextToken": null
}
packages/amplify_api/lib/src/graphql/paginated_result_impl.dart
Outdated
Show resolved
Hide resolved
packages/amplify_api_plugin_interface/lib/src/types/pagination/paginated_modelType.dart
Outdated
Show resolved
Hide resolved
packages/amplify_api/lib/src/graphql/paginated_result_impl.dart
Outdated
Show resolved
Hide resolved
packages/amplify_api/lib/src/graphql/paginated_modelType_impl.dart
Outdated
Show resolved
Hide resolved
packages/amplify_api/lib/src/graphql/paginated_result_impl.dart
Outdated
Show resolved
Hide resolved
packages/amplify_api/lib/src/graphql/graphql_request_factory.dart
Outdated
Show resolved
Hide resolved
packages/amplify_api/lib/src/graphql/model_queries_factory.dart
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Booya 😎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢 it ! Great job.
Hello , |
@rahul-readwhere were you not able to find the ModelTodoFilterInput in your local schema or in the version you see in the AppSync Console? For a small example I have, I noticed that the ModelTodoFilterInput is in the the schema on AWS AppSync Console under AWS AppSync > [backendName] > Schema. For my case, this was created by Amplify when setting up the API resource in my app, which I created from a very basic schema |
* chore(amplify_api): GraphQL helper move dependencies (#729) * feat(amplify_api): GraphQL helper get query (#742) * feat(amplify_api): GraphQL Response Decoding (#763) * feat(amplify_api): GraphQL Query Helper - List (#771) * feat(amplify_api): GraphQL Mutate Helper - Create (#778) * feat(amplify_api): GraphQL Mutate Helper - Update (#779) * feat(amplify_api): GraphQL Mutate Helper - Delete (#780) * feat(amplify_api): GraphQL Helpers Integration Tests (#785) * fix(amplify_api): GraphQL Helper Clean Up (#803) * some fixes for merge * fix integration tests and some related analyze issues * update graphql helpers to pass analysis * correct some rebase errors Co-authored-by: Elijah Quartey <[email protected]>
* chore(amplify_api): GraphQL helper move dependencies (#729) * feat(amplify_api): GraphQL helper get query (#742) * feat(amplify_api): GraphQL Response Decoding (#763) * feat(amplify_api): GraphQL Query Helper - List (#771) * feat(amplify_api): GraphQL Mutate Helper - Create (#778) * feat(amplify_api): GraphQL Mutate Helper - Update (#779) * feat(amplify_api): GraphQL Mutate Helper - Delete (#780) * feat(amplify_api): GraphQL Helpers Integration Tests (#785) * fix(amplify_api): GraphQL Helper Clean Up (#803) * graphql helpers: slight refactor to datastore interface QueryFieldOpe… (#962) * Graphql helpers pagination helpers (#947) * Graphql helpers: query predicates translated to filters and conditions for GraphQL requests (#973) * chore(amplify_api): graphql helpers, add parent selection set for models with belongsTo, transform JSON in response for parents and children * chore(amplify_api): parse nested responses recursively * chore(amplify_api): make data nullable in graphql responses (#1007) * chore(amplify_api): graphql helpers, mutations on models with parents (#1004) * feat(amplify_api): Graphql helpers, include parent and decode nested/parent values (#1055) Co-authored-by: Elijah Quartey <[email protected]> BREAKING CHANGE: data field nullable in GraphQLResponse
* feat(amplify_api): model-based graphql helpers (#1076) * chore(amplify_api): GraphQL helper move dependencies (#729) * feat(amplify_api): GraphQL helper get query (#742) * feat(amplify_api): GraphQL Response Decoding (#763) * feat(amplify_api): GraphQL Query Helper - List (#771) * feat(amplify_api): GraphQL Mutate Helper - Create (#778) * feat(amplify_api): GraphQL Mutate Helper - Update (#779) * feat(amplify_api): GraphQL Mutate Helper - Delete (#780) * feat(amplify_api): GraphQL Helpers Integration Tests (#785) * fix(amplify_api): GraphQL Helper Clean Up (#803) * graphql helpers: slight refactor to datastore interface QueryFieldOpe… (#962) * Graphql helpers pagination helpers (#947) * Graphql helpers: query predicates translated to filters and conditions for GraphQL requests (#973) * chore(amplify_api): graphql helpers, add parent selection set for models with belongsTo, transform JSON in response for parents and children * chore(amplify_api): parse nested responses recursively * chore(amplify_api): make data nullable in graphql responses (#1007) * chore(amplify_api): graphql helpers, mutations on models with parents (#1004) * feat(amplify_api): Graphql helpers, include parent and decode nested/parent values (#1055) Co-authored-by: Elijah Quartey <[email protected]> BREAKING CHANGE: data field nullable in GraphQLResponse
Issue #, if available:
Partial implementation of GraphQL model helper feature #308.
Description of changes:
This adds
ModelQueries.list()
, allows for proper response decoding of PaginatedResults, and relevant unit tests.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.