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

227
Views
Delete Data using react.js and graphql

I would like to ask why I cannot delete data on graphql using react.js and apollo?... The code doesn't give any errors... I have tried deleting on graphiql and on django-admin(server-side)and it works just fine...

const QUERY_CLIENTS = gql`
query{
  allClients{
    id
    age
    name
    gender
    homeAddress
    contactNumber
    emailAddress
  }
}
`;
const DELETE_CLIENT = gql`
mutation deleteClient($id: Int!){
  deleteClient(id:$id){
    client{
      id
    }
  }
}
`;
function DisplayClients(){
  const {loading, error, data} = useQuery(QUERY_CLIENTS);
  const [deleteClient] = useMutation(DELETE_CLIENT);

  const removeClient = (id) => {
    deleteClient(
      {
        variables: {
          id: id
        }
      }
    );
    window.location.reload();
  }

  if (loading) return <p>loading...</p>;
  if(error) return <p>Error: (</p>;

  return data.allClients.map(({id, age, name, gender, homeAddress, contactNumber, emailAddress}) => (
    <div key={id}>
      <p>
        {id} {name} {age} {gender} {homeAddress} {contactNumber} {emailAddress}
        <button onClick={() => removeClient(id)}>Delete</button>
      </p>
    </div>
    
  ));
}

Thank you :)

about 4 years ago · Juan Pablo Isaza
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!