-1

I have following simple selection query in GraphQL which checks if in dataDictionary table any record exists with name field dataDict101.

query dataDictionary($where : DataDictionaryWhereUniqueInput!){
  dataDictionary(where: $where){
    id
  }
}
,
variables: {
data: {
       "where" : {
            "name": "dataDict101"
            } 
      }
}

How can I determine if above query returned any row or not? e.g. Similar to SQL query returns SQLCODE=0 or SQL%ROWCOUNT>0 in case of cursor if record found.

Chin Huang
  • 12,912
  • 4
  • 46
  • 47
Data_Geek
  • 11
  • 4

1 Answers1

0
    export const FIND_DATA_DICTIONARY = gql`
    query dataDictionary($where : DataDictionaryWhereUniqueInput!){
      dataDictionary(where: $where){
        id
      }
    }
    `;
    const result = await client.query({
          query: FIND_DATA_DICTIONARY,
          variables: {
                where : {
                     name: data.name,
                } 
            
          },
        });
        resultData = result;

  if(resultData?.data.dataDictionary != null)
  console.log('data found');

Checking not null value of data.dataDictionary from result, I was able to determine if row is returned or not.

Data_Geek
  • 11
  • 4