Skip to main content
GraphQL

Update Mutation

QueryParseValidateMedium

Description

Update an existing resource with partial data.

Test Scenario

const mutation = `
  mutation UpdateUser($id: ID!, $input: UpdateUserInput!) {
    updateUser(id: $id, input: $input) {
      id
      name
      updatedAt
    }
  }
`;
Endpoint/api/graphql

Testing Tips

  • •Only send fields to update
  • •Handle null vs undefined
  • •Return updated fields
// Playwright API Testing - GraphQL
import { test, expect } from '@playwright/test';
test('GraphQL query', async ({ request }) => {
const response = await request.post('/api/graphql', {
data: {
query: `
query {
users {
id
name
email
}
}
`
}
});
expect(response.ok()).toBeTruthy();
const { data } = await response.json();
expect(data.users).toBeDefined();
});

Challenge ID: graphql-mutation-update

2 frameworks available

API Playground

Send requests and inspect responses

Endpoint: /api/graphql

Press Enter to send