Apollo Client React: how to pass the data obtained from a query as an argument in another query in graphql?

Viewed 205

I am using Apollo client in React, I have two queries. At the first, it will return the phone value and the second uses the phone as a parameter. I want two queries run one by one and return value from two queries at the end of the pipe. I don't know Apollo client in react can do that or not?

export const GET_DETAIL = gql`
  query GetDetail($id: uuid!) {
    data: data_user_by_pk(id: $id) {
      phone
    }
  }
`;

export const GET_DETAIL_BY_PHONE = gql`
  query GetDetailByPhone($phone: String!) {
    data: data_user_get_checked_in_companies_by_phone(input: { phone_number: $phone }) {
      name
}

} `;

0 Answers
Related