I'm facing issues while migrating from API.graphql to AWS AppSync SDK using AWSAppSyncClient.
All examples below work fine while using API.graphql, but, when we start to use AppSync, only simple queries works. Queries with more complex filters using appsync return an empty array.
// AppSync Client [AWS AppSync SDK]
import { Auth } from '@aws-amplify/auth'
import AWSAppSyncClient, { AUTH_TYPE } from 'aws-appsync'
import getEnvVars from '../../environment'
const { appSync } = getEnvVars()
const getJwtToken = async () =>
(await Auth.currentSession()).getAccessToken().getJwtToken()
const client = new AWSAppSyncClient({
url: appSync.aws_appsync_graphqlEndpoint,
region: appSync.aws_project_region,
auth: {
type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
jwtToken: getJwtToken,
},
disableOffline: false,
})
// CASE 1
// Simple filter using "eq"
const works = await client.query<
ListSavedJobsQuery,
ListSavedJobsQueryVariables
>(listSavedJobs, {
filter: {
userID: {
eq: 'wenderson',
},
},
})
// CASE 2
// Fetch all Projects without filtering - works fine
const works2 = await client.query<
ListJobsQuery,
ListJobsQueryVariables
>(listJobs)
// CASE 3
// List of "or" filter - doesn't work
const doesnWork = await client.query<
ListJobsQuery,
ListJobsQueryVariables
>(listJobs, {
filter: {
or: [
{ Job: { eq: 1 } },
{ Job: { eq: 2 } },
{ Job: { eq: 3 } },
{ Job: { eq: 4 } },
// ... and more,
],
},
})
// CASE 4
// Doesn't work
const doesntWork2 = await client.query<
ListJobsStateQuery,
ListJobsStateQueryVariables
>(listJobsStates, {
filter: {
or: [{ Field: { eq: Y } }, { Office: { eq: Y } }],
},
})
I'm facing issues while migrating from API.graphql to AWS AppSync SDK using AWSAppSyncClient.
All examples below work fine while using API.graphql, but, when we start to use AppSync, only simple queries works. Queries with more complex filters using appsync return an empty array.
This is our current package.json content:
In a try to keep going with the project, we're storing all data locally without filtering and then making a manual filter, but it takes so much time.
Appreciate any help on this.