Skip to main content

Overview

The 5Stack GraphQL API provides comprehensive queries for fetching data about players, matches, tournaments, servers, and game statistics. All queries use the Zeus code generation system for type safety.

Query Structure

Queries are generated using the generateQuery helper function:
import { generateQuery } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';

const query = generateQuery({
  // Your query fields here
});

Player Queries

Get Player Profile

Fetch a single player’s profile by Steam ID:
import { generateQuery } from '@/graphql/graphqlGen';
import { playerFields } from '@/graphql/playerFields';
import { $ } from '@/generated/zeus';

const query = generateQuery({
  players_by_pk: [
    { steam_id: $('steam_id', 'String!') },
    playerFields
  ]
});
players_by_pk
Player
Returns a single player object

Get Current User (Me)

Fetch the authenticated user’s complete profile:
import { generateQuery } from '@/graphql/graphqlGen';
import { meFields } from '@/graphql/meGraphql';
import { $ } from '@/generated/zeus';

const query = generateQuery({
  players_by_pk: [
    { steam_id: $('steam_id', 'String!') },
    meFields
  ]
});
The meFields selector includes additional fields only available to the authenticated user:
  • name_registered: Whether the player has registered their name
  • profile_url: Custom profile URL
  • matchmaking_cooldown: Matchmaking cooldown timestamp
  • current_lobby_id: Current lobby UUID
  • language: Preferred language code
  • teams: Array of teams the player belongs to

List Players

Query multiple players with filtering and pagination:
import { generateQuery } from '@/graphql/graphqlGen';
import { playerFields } from '@/graphql/playerFields';

const query = generateQuery({
  players: [
    {
      where: {
        elo: { _gte: 1000 },
        is_banned: { _eq: false }
      },
      order_by: [{ elo: 'desc' }],
      limit: 50,
      offset: 0
    },
    playerFields
  ]
});

Match Queries

Get Match Details

Fetch a single match with full details:
import { generateQuery } from '@/graphql/graphqlGen';
import { simpleMatchFields } from '@/graphql/simpleMatchFields';
import { $ } from '@/generated/zeus';

const query = generateQuery({
  matches_by_pk: [
    { id: $('match_id', 'uuid!') },
    simpleMatchFields
  ]
});
matches_by_pk
Match
Returns a complete match object

Get Match Lineups with Stats

Fetch detailed lineup information with player statistics:
import { generateQuery } from '@/graphql/graphqlGen';
import { matchLineups } from '@/graphql/matchLineupsGraphql';
import { $ } from '@/generated/zeus';

const query = generateQuery({
  match_lineups: [
    {
      where: {
        match_id: { _eq: $('matchId', 'uuid!') }
      }
    },
    matchLineups
  ]
});
This query includes comprehensive player statistics:
  • Kills, deaths, assists (KDA)
  • Headshot kills
  • Multi-kills
  • Damage dealt and received
  • Flash assists and enemies flashed
  • Utility usage (smokes, flashes, HE grenades, molotovs)
  • Team damage statistics

List Recent Matches

import { generateQuery } from '@/graphql/graphqlGen';
import { simpleMatchFields } from '@/graphql/simpleMatchFields';
import { order_by } from '@/generated/zeus';

const query = generateQuery({
  matches: [
    {
      where: {
        status: { _eq: 'Ended' }
      },
      order_by: [{ ended_at: order_by.desc }],
      limit: 20
    },
    simpleMatchFields
  ]
});

Tournament Queries

Get Tournament Details

import { generateQuery } from '@/graphql/graphqlGen';
import { simpleTournamentFields } from '@/graphql/simpleTournamentFields';
import { $ } from '@/generated/zeus';

const query = generateQuery({
  tournaments_by_pk: [
    { id: $('tournament_id', 'uuid!') },
    simpleTournamentFields
  ]
});
tournaments_by_pk
Tournament
Returns a tournament object with stages and teams

Get Tournament Teams

import { generateQuery } from '@/graphql/graphqlGen';
import { tournamentTeamFields } from '@/graphql/tournamentTeamFields';
import { $ } from '@/generated/zeus';

const query = generateQuery({
  tournament_teams: [
    {
      where: {
        tournament_id: { _eq: $('tournament_id', 'uuid!') }
      }
    },
    tournamentTeamFields
  ]
});

List Active Tournaments

import { generateQuery } from '@/graphql/graphqlGen';
import { simpleTournamentFields } from '@/graphql/simpleTournamentFields';

const query = generateQuery({
  tournaments: [
    {
      where: {
        e_tournament_status: {
          description: { _in: ['Active', 'Registration Open'] }
        }
      },
      order_by: [{ start: 'asc' }]
    },
    simpleTournamentFields
  ]
});

Map Queries

Get Available Maps

import { generateQuery } from '@/graphql/graphqlGen';
import { mapFields } from '@/graphql/mapGraphql';

const query = generateQuery({
  maps: [
    {
      where: {
        enabled: { _eq: true },
        active_pool: { _eq: true }
      },
      order_by: [{ name: 'asc' }]
    },
    mapFields
  ]
});
maps
Map[]
Returns array of map objects

Get Map Pools

import { generateQuery } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';

const query = generateQuery({
  map_pools: [
    {
      where: {
        enabled: { _eq: true }
      }
    },
    {
      id: true,
      name: true,
      type: true,
      map_pool_maps: [
        {},
        {
          map: {
            id: true,
            name: true,
            label: true,
            poster: true
          }
        }
      ]
    }
  ]
});

Server Queries

Get Dedicated Server

import { generateQuery } from '@/graphql/graphqlGen';
import { $ } from '@/generated/zeus';

const query = generateQuery({
  servers_by_pk: [
    { id: $('serverId', 'uuid!') },
    {
      id: true,
      name: true,
      ip: true,
      port: true,
      status: true,
      max_players: true,
      current_map: true,
      game_server_node: {
        id: true,
        name: true,
        region: true
      }
    }
  ]
});

List Available Servers

import { generateQuery } from '@/graphql/graphqlGen';

const query = generateQuery({
  servers: [
    {
      where: {
        status: { _eq: 'Available' },
        enabled: { _eq: true }
      }
    },
    {
      id: true,
      name: true,
      region: true,
      max_players: true
    }
  ]
});

Filtering and Sorting

Comparison Operators

Use these operators in where clauses:
  • _eq: Equal to
  • _neq: Not equal to
  • _gt: Greater than
  • _gte: Greater than or equal to
  • _lt: Less than
  • _lte: Less than or equal to
  • _in: In array
  • _nin: Not in array
  • _like: Pattern matching (SQL LIKE)
  • _ilike: Case-insensitive pattern matching

Ordering

import { order_by } from '@/generated/zeus';

const query = generateQuery({
  players: [
    {
      order_by: [
        { elo: order_by.desc },
        { name: order_by.asc }
      ]
    },
    playerFields
  ]
});

Pagination

const ITEMS_PER_PAGE = 50;
const page = 1;

const query = generateQuery({
  matches: [
    {
      limit: ITEMS_PER_PAGE,
      offset: (page - 1) * ITEMS_PER_PAGE,
      order_by: [{ created_at: order_by.desc }]
    },
    simpleMatchFields
  ]
});

Aggregations

Get aggregate data like counts, sums, and averages:
const query = generateQuery({
  players_aggregate: [
    {
      where: {
        elo: { _gte: 1000 }
      }
    },
    {
      aggregate: {
        count: true,
        avg: { elo: true },
        max: { elo: true },
        min: { elo: true }
      }
    }
  ]
});

Next Steps

Mutations

Learn how to create and update data

Subscriptions

Set up real-time data subscriptions

Build docs developers (and LLMs) love