Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
Filter queries from Graph QL based on a filter

I'm trying to call a graph ql query where I want to filter the values based on a variable (MeetingID) value given by the user.

    var MeetingID
    const handleUserInputChange = (e) => {
         MeetingID = e.target.name;
    
  };
    const querysort = Object.assign({},{
            sortDirection : 'ASC' ,type : 'datamodel', MeetingID: MeetingID
          })
    
    async function fetchTrans() {
            try {
              const transData = await API.graphql(graphqlOperation(datamodel,querysort, { filter: { MeetingID: MeetingID } }));
              console.log(transData);
              //const transData = await API.graphql(graphqlOperation(datamodelByDate,variables));
              const datamodels = transData.data.datamodel.items;
              setValue(datamodels)
              //console.log(transData.data.datamodelByDate.items)
            } catch (err) { console.log('error fetching transcription:', err) }
          }

And this my generated query by amplify codegen

export const datamodel = /* GraphQL */ `
  query Datamodel(
    $type: String!
    $createdAt: ModelStringKeyConditionInput
    $sortDirection: ModelSortDirection
    $filter: ModelDatamodelFilterInput
    $limit: Int
    $nextToken: String
  ) {
    datamodel(
      type: $type
      createdAt: $createdAt
      sortDirection: $sortDirection
      filter: $filter
      limit: $limit
      nextToken: $nextToken
    ) {
      items {
        id
        MeetingID
        Transcription
        createdAt
        type
        updatedAt
      }
      nextToken
    }
  }
`;

I'm getting all the transcriptions even though I have applied the query.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to specify the operator

var MeetingID;

const querysort = Object.assign({},{
  sortDirection : 'ASC', 
  type : 'datamodel', 
  filter: { MeetingID: { eq: MeetingID } }
})

await API.graphql(graphqlOperation(datamodel, querysort))
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!