Selected field names (tracked through chaining for precise autocomplete)
Included relations (tracked through chaining with proper cardinality)
Protected OptionalapiPer-call API key override, set via apiKey.
ProtectedfiltersProtectedqueryProtectedselectedProtectedskipWhen true, this call bypasses the response cache. Set via skipCache.
ProtectedsubqueriesProtected Static ReadonlyMAX_Protected Static ReadonlyMAX_Protected Static ReadonlyMAX_Protected Static ReadonlyMAX_Protected Static ReadonlyMAX_Protected Static ReadonlyMAX_Protected Static ReadonlyQUERIES_Queries that return data directly without wrapping in a 'data' object. These queries follow a different GraphQL schema structure.
Use a specific API key for this call instead of the client's default key.
The Politics & War API key to authenticate this query with.
This query builder instance for method chaining.
ProtectedbuildBuild the final GraphQL query string with comprehensive validation.
Constructs a complete GraphQL query including:
Validation includes:
Whether to include pagination info in response
Complete GraphQL query string ready for execution
Execute the treasures query and return results.
Return type changes based on withPaginator parameter:
execute() or execute(false) → Returns array of treasuresexecute(true) → Returns object with data array and paginatorInfoResults only include selected fields and included relations. All other fields are excluded from the response.
Array of treasures, or object with data and paginatorInfo if withPaginator is true
// Returns array directly
const treasures = await query.execute();
// Type: { name: string, bonus: number }[]
treasures.forEach(treasure => console.log(treasure.name, treasure.bonus));
// Returns object with pagination info
const result = await query.execute(true);
// Type: { data: {...}[], paginatorInfo: {...} }
console.log(result.data); // Treasures array
console.log(result.paginatorInfo.total); // Total count
console.log(result.paginatorInfo.currentPage); // Current page number
Execute the treasures query and return results.
Return type changes based on withPaginator parameter:
execute() or execute(false) → Returns array of treasuresexecute(true) → Returns object with data array and paginatorInfoResults only include selected fields and included relations. All other fields are excluded from the response.
Array of treasures, or object with data and paginatorInfo if withPaginator is true
// Returns array directly
const treasures = await query.execute();
// Type: { name: string, bonus: number }[]
treasures.forEach(treasure => console.log(treasure.name, treasure.bonus));
// Returns object with pagination info
const result = await query.execute(true);
// Type: { data: {...}[], paginatorInfo: {...} }
console.log(result.data); // Treasures array
console.log(result.paginatorInfo.total); // Total count
console.log(result.paginatorInfo.currentPage); // Current page number
Include related data in the query results
Supports unlimited recursive nesting with full type inference at every level. Each nested builder receives complete type safety for fields, relations, and query parameters.
New query instance with included relation
// Basic subquery with field selection
.include('nation', builder => builder
.select('id', 'nation_name', 'score')
)
// Subquery with filtering and nesting
.include('nation', builder => builder
.select('id', 'nation_name')
.where({ min_score: 1000 })
.include('alliance', builder2 => builder2 // Unlimited nesting!
.select('id', 'name', 'score')
)
)
// Important: Always select at least one scalar field at each level
// GraphQL requires this - you cannot query an object without selecting fields
ProtectedsanitizeSanitize and escape a string value for safe GraphQL usage.
Validates input type and length, checks for null bytes, and escapes special characters including backslashes, quotes, newlines, carriage returns, tabs, form feeds, and backspaces.
The string to sanitize
Sanitized string with all special characters properly escaped
Select specific fields to retrieve from treasures
Field names to select
New query instance with selected fields
ProtectedserializeSerialize an object to GraphQL format (enum values without quotes).
Validates object structure and prevents prototype pollution by:
Plain object to serialize (not arrays)
GraphQL-formatted object string in format {key:value, ...}
Bypass the response cache for this call.
Only meaningful when caching is enabled on the client (cache.enabled).
The result is fetched fresh from the API and is neither read from nor
written to the cache. No effect when caching is disabled.
This query builder instance for method chaining.
Query builder for fetching treasure data from the Politics & War API.
Create new instances using the factory method:
pnwkit.queries.treasures()Each call creates a fresh instance with no shared state, preventing filter pollution.Treasures are special bonus items that can be obtained through various means in the game.
Features:
Return types:
execute()→ Returns array of treasuresexecute(true)→ Returns{ data: Treasure[], paginatorInfo: {...} }Example