NYYU Logo
APIUser Tier

Add New Tier

Create a new tier level in the gamification system (Admin only)

Add New Tier

ADMIN

Create new tier levels for user progression

Admin Access Required

This mutation is accessible only to users with ADMIN privileges. Unauthorized access will be denied.

Overview

The addNewUserTier mutation allows administrators to create new tier levels in the gamification system. Define tier names, point requirements, and visual badges to expand the progression ladder.

GraphQL Schema

🔧
Mutation Definition
Creates a new tier in the system
addNewUserTier(
  level: Int!
  name: String!
  point: Float!
  svg: String!
): Tier

Parameters

📝
Required Fields
All parameters are mandatory
level
Tier LevelInt!

Unique identifier for the tier (e.g., 1, 2, 3). Must not conflict with existing tiers.

name
Tier NameString!

Display name for the tier (e.g., "Bronze", "Silver", "Gold").

point
Points RequiredFloat!

Minimum points needed to reach this tier (e.g., 1000.0).

svg
Badge SVGString!

SVG markup for the tier badge icon (e.g., "<svg>...</svg>").

Return Type

📦
Tier Object
Returns the newly created tier on success, null on failure
type Tier {
  level: Int!
  name: String
  point: Float
  svg: String
}

Example Mutation

Creating Bronze Tier

mutation {
  addNewUserTier(
    level: 1
    name: "Bronze"
    point: 1000.0
    svg: "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='#CD7F32' d='M12 2L15.09 8.26L22 9.27L17 14.14L18.18 21.02L12 17.77L5.82 21.02L7 14.14L2 9.27L8.91 8.26L12 2Z'/></svg>"
  ) {
    level
    name
    point
    svg
  }
}

Example Response

Success Response
Tier created successfully
{
  "data": {
    "addNewUserTier": {
      "level": 1,
      "name": "Bronze",
      "point": 1000,
      "svg": "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='#CD7F32' d='M12 2L15.09 8.26L22 9.27L17 14.14L18.18 21.02L12 17.77L5.82 21.02L7 14.14L2 9.27L8.91 8.26L12 2Z'/></svg>"
    }
  }
}

Complete Tier Examples

🏆
Standard Tier Setup
Create a complete progression system
1
Bronze Tier

level: 1 | name: "Bronze" | point: 1000.0

2
Silver Tier

level: 2 | name: "Silver" | point: 5000.0

3
Gold Tier

level: 3 | name: "Gold" | point: 15000.0

4
Platinum Tier

level: 4 | name: "Platinum" | point: 50000.0

5
Diamond Tier

level: 5 | name: "Diamond" | point: 150000.0

Use Cases

🎮
Initial Setup

Create the complete tier structure when launching your gamification system

📈
Expansion

Add higher tiers as your user base grows and engagement increases

🎯
Seasonal Events

Create limited-time special tiers for events and promotions

🏅
Elite Recognition

Add premium tiers to recognize and reward your most engaged users

Best Practices

📊
Progressive Point Requirements

Ensure each tier requires significantly more points than the previous one to create meaningful progression (e.g., 1000, 5000, 15000, 50000)

🎨
Consistent Badge Design

Use consistent SVG dimensions and styling across all tier badges for uniform display (recommended: 24x24 viewBox)

🔢
Sequential Levels

Maintain sequential level numbers without gaps to simplify tier logic and user understanding

Validate Before Creating

Check for level conflicts with getUserTiers before creating new tiers to prevent duplication errors

💬
Meaningful Names

Choose tier names that convey prestige and achievement (Bronze, Silver, Gold, Platinum, Diamond)

Implementation Example

💻
Admin Implementation
Create multiple tiers programmatically
// Define tier structure
const tiers = [
  { level: 1, name: "Bronze", point: 1000, color: "#CD7F32" },
  { level: 2, name: "Silver", point: 5000, color: "#C0C0C0" },
  { level: 3, name: "Gold", point: 15000, color: "#FFD700" },
  { level: 4, name: "Platinum", point: 50000, color: "#E5E4E2" },
  { level: 5, name: "Diamond", point: 150000, color: "#B9F2FF" }
];

// Generate SVG badge
const createBadgeSVG = (color: string) => {
  return `<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'>
    <path fill='${color}' d='M12 2L15.09 8.26L22 9.27L17 14.14L18.18 21.02L12 17.77L5.82 21.02L7 14.14L2 9.27L8.91 8.26L12 2Z'/>
  </svg>`;
};

// Create each tier
for (const tier of tiers) {
  const { data } = await client.mutate({
    mutation: gql`
      mutation AddTier($level: Int!, $name: String!, $point: Float!, $svg: String!) {
        addNewUserTier(
          level: $level
          name: $name
          point: $point
          svg: $svg
        ) {
          level
          name
          point
        }
      }
    `,
    variables: {
      level: tier.level,
      name: tier.name,
      point: tier.point,
      svg: createBadgeSVG(tier.color)
    }
  });

  console.log(`Created tier: ${data.addNewUserTier.name}`);
}

Error Handling

⚠️
Common Errors
Handle these scenarios gracefully
Duplicate Level

Attempting to create a tier with an existing level number will fail. Check existing tiers first.

Invalid SVG

Malformed SVG markup may cause rendering issues. Validate SVG syntax before submission.

Unauthorized Access

Non-admin users will receive an authorization error. Ensure proper role verification.

Admin Operation

Only administrators can create new tiers. This operation affects the entire gamification system structure.