DEV Community

Discussion on: Data Modeling in Depth with GraphQL & AWS Amplify - 17 Data Access Patterns

Collapse
petroslafaz profile image
Petros Lafazanidis

Thank you Nader this is a fantastic resource.

A bit late here in London, so I might be missing the obvious, but anyways here is a pedestrian question about item 14.
The same can be achieved by

listEmployees(filter: {jobTitle: {eq: "Manager"}})

with the benefit of being able to use filter with other operators. So what is the benefit of your approach? Is is performance mainly?

thanks
Petros

Collapse
dabit3 profile image
Nader Dabit Author

So either can be used, but the query on index is preferred because a filter with scan will scan the entire database and then discard the items based on the filter, while the query will only query the items needed so the operation is less expensive in general.