Overview
Mutations allow you to create, update, and delete data in the 5Stack platform. All mutations use the Zeus code generation system for type safety and are generated using thegenerateMutation helper.
Mutation Structure
Mutations are generated using thegenerateMutation helper function:
import { generateMutation } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';
const mutation = generateMutation({
// Your mutation fields here
});
Player Mutations
Update Player Name
Update a player’s display name:import { generateMutation } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';
const mutation = generateMutation({
update_players_by_pk: [
{
pk_columns: { steam_id: $('steam_id', 'String!') },
_set: {
name: $('player_name', 'String!')
}
},
{
steam_id: true,
name: true
}
]
});
Primary key columns to identify the player
Show Properties
Show Properties
Player’s Steam ID
Request Name Change
Request a name change (requires moderation approval):import { generateMutation } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';
const mutation = generateMutation({
requestNameChange: [
{
steam_id: $('steam_id', 'String!'),
name: $('new_name', 'String!')
},
{
success: true,
message: true
}
]
});
Match Mutations
Accept Match Invite
Accept an invitation to join a match:import { generateMutation } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';
const mutation = generateMutation({
acceptInvite: [
{
type: $('invite_type', 'String!'), // 'match' or 'tournament'
invite_id: $('invite_id', 'uuid!')
},
{
success: true,
message: true
}
]
});
Type of invite:
match or tournamentUUID of the invitation
Deny Match Invite
Decline an invitation:import { generateMutation } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';
const mutation = generateMutation({
denyInvite: [
{
type: $('invite_type', 'String!'),
invite_id: $('invite_id', 'uuid!')
},
{
success: true
}
]
});
Submit Map Veto
Pick or ban a map during the veto phase:import { generateMutation } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';
import { e_veto_pick_types_enum } from '@/generated/zeus';
const mutation = generateMutation({
insert_match_map_vetos_one: [
{
object: {
match_id: $('match_id', 'uuid!'),
match_lineup_id: $('lineup_id', 'uuid!'),
map_id: $('map_id', 'uuid!'),
type: e_veto_pick_types_enum.Pick, // or Ban
side: $('side', 'String') // 'CT' or 'T' for picks
}
},
{
id: true,
map: {
name: true,
label: true
},
type: true,
side: true
}
]
});
Create Match
import { generateMutation } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';
const mutation = generateMutation({
insert_matches_one: [
{
object: {
organizer_steam_id: $('organizer_steam_id', 'String!'),
status: 'Pending',
options: {
data: {
best_of: 1,
mr: 12,
type: 'Competitive',
lobby_access: 'Public'
}
},
lineup_1: {
data: {
name: $('team1_name', 'String!')
}
},
lineup_2: {
data: {
name: $('team2_name', 'String!')
}
}
}
},
{
id: true,
status: true,
lineup_1: { id: true, name: true },
lineup_2: { id: true, name: true }
}
]
});
Update Match Status
import { generateMutation } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';
const mutation = generateMutation({
update_matches_by_pk: [
{
pk_columns: { id: $('match_id', 'uuid!') },
_set: {
status: $('new_status', 'String!')
}
},
{
id: true,
status: true
}
]
});
Add Player to Lineup
import { generateMutation } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';
const mutation = generateMutation({
insert_lineup_players_one: [
{
object: {
match_lineup_id: $('lineup_id', 'uuid!'),
steam_id: $('player_steam_id', 'String!'),
captain: false,
checked_in: false
}
},
{
steam_id: true,
player: {
name: true,
avatar_url: true
}
}
]
});
Tournament Mutations
Create Tournament
import { generateMutation } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';
const mutation = generateMutation({
insert_tournaments_one: [
{
object: {
name: $('tournament_name', 'String!'),
description: $('description', 'String!'),
start: $('start_date', 'timestamp!'),
status: 'Registration Open',
options: {
data: {
best_of: 3,
mr: 12,
type: 'Competitive'
}
}
}
},
{
id: true,
name: true,
start: true
}
]
});
Register Team for Tournament
import { generateMutation } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';
const mutation = generateMutation({
insert_tournament_teams_one: [
{
object: {
tournament_id: $('tournament_id', 'uuid!'),
team_id: $('team_id', 'uuid!'),
seed: $('seed', 'Int')
}
},
{
id: true,
team: {
name: true,
short_name: true
}
}
]
});
Add Tournament Stage
import { generateMutation } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';
const mutation = generateMutation({
insert_tournament_stages_one: [
{
object: {
tournament_id: $('tournament_id', 'uuid!'),
type: $('stage_type', 'String!'), // 'Groups', 'Bracket', etc.
order: $('stage_order', 'Int!'),
default_best_of: 3,
third_place_match: false
}
},
{
id: true,
type: true,
order: true
}
]
});
Team Mutations
Create Team
import { generateMutation } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';
const mutation = generateMutation({
insert_teams_one: [
{
object: {
name: $('team_name', 'String!'),
short_name: $('short_name', 'String!'),
captain_steam_id: $('captain_steam_id', 'String!')
}
},
{
id: true,
name: true,
short_name: true
}
]
});
Add Player to Team
import { generateMutation } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';
const mutation = generateMutation({
insert_team_players_one: [
{
object: {
team_id: $('team_id', 'uuid!'),
steam_id: $('player_steam_id', 'String!'),
role: 'Member' // 'Captain', 'Member', 'Coach'
}
},
{
team_id: true,
steam_id: true,
role: true
}
]
});
Bulk Operations
Insert Multiple Records
Insert multiple records in a single mutation:import { generateMutation } from '@/graphql/graphqlGen';
const mutation = generateMutation({
insert_lineup_players: [
{
objects: [
{
match_lineup_id: lineupId,
steam_id: 'player1_steam_id',
captain: true
},
{
match_lineup_id: lineupId,
steam_id: 'player2_steam_id',
captain: false
},
{
match_lineup_id: lineupId,
steam_id: 'player3_steam_id',
captain: false
}
]
},
{
affected_rows: true,
returning: {
steam_id: true,
player: { name: true }
}
}
]
});
Update Multiple Records
import { generateMutation } from '@/graphql/graphqlGen';
const mutation = generateMutation({
update_lineup_players: [
{
where: {
match_lineup_id: { _eq: lineupId }
},
_set: {
checked_in: true
}
},
{
affected_rows: true
}
]
});
Delete Records
import { generateMutation } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';
const mutation = generateMutation({
delete_lineup_players: [
{
where: {
match_lineup_id: { _eq: $('lineup_id', 'uuid!') },
steam_id: { _eq: $('player_steam_id', 'String!') }
}
},
{
affected_rows: true
}
]
});
Conditional Operations
Upsert (Insert or Update)
import { generateMutation } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';
const mutation = generateMutation({
insert_player_settings_one: [
{
object: {
steam_id: $('steam_id', 'String!'),
setting_key: 'preferred_region',
setting_value: 'EU'
},
on_conflict: {
constraint: 'player_settings_pkey',
update_columns: ['setting_value']
}
},
{
steam_id: true,
setting_key: true,
setting_value: true
}
]
});
Error Handling
Mutations return errors in the standard GraphQL format:try {
const result = await apolloClient.mutate({
mutation,
variables: { player_name: 'NewName' }
});
console.log('Success:', result.data);
} catch (error) {
if (error.graphQLErrors) {
error.graphQLErrors.forEach((err) => {
console.error('GraphQL Error:', err.message);
});
}
if (error.networkError) {
console.error('Network Error:', error.networkError);
}
}
Next Steps
Queries
Learn how to fetch data after mutations
Subscriptions
Subscribe to real-time updates after mutations