NYYU Logo
APIUser Tier

Update User Tier

Modify existing tier configurations in the gamification system (Admin only)

โœ๏ธ

Update User Tier

ADMIN

Modify tier names, points, or badges

Admin Access Required

This mutation is accessible only to users with ADMIN privileges. Changes affect all users at that tier level.

Overview

The updateUserTier mutation allows administrators to modify existing tier configurations. Update tier names, adjust point requirements, or refresh badge designs while preserving the tier level identifier.

GraphQL Schema

๐Ÿ”ง
Mutation Definition
Updates an existing tier by level
updateUserTier(
  level: Int!
  name: String
  point: Float
  svg: String
): Tier

Parameters

๐Ÿ“
Update Fields
Level is required, other fields are optional
level
Tier LevelInt!Required

The level identifier of the tier to update. Cannot be changed.

name
Tier NameStringOptional

New display name for the tier (e.g., "Elite Bronze", "Premium Silver").

point
Points RequiredFloatOptional

Updated point threshold (e.g., adjust from 1000.0 to 1200.0).

svg
Badge SVGStringOptional

Updated SVG markup for refreshed badge design.

Return Type

๐Ÿ“ฆ
Updated Tier Object
Returns the modified tier on success, null if tier not found
type Tier {
  level: Int!
  name: String
  point: Float
  svg: String
}

Example Mutations

Update Tier Name

mutation {
  updateUserTier(
    level: 1
    name: "Elite Bronze"
  ) {
    level
    name
    point
    svg
  }
}

Adjust Point Requirement

mutation {
  updateUserTier(
    level: 2
    point: 6000.0
  ) {
    level
    name
    point
  }
}

Complete Update

mutation {
  updateUserTier(
    level: 3
    name: "Premium Gold"
    point: 20000.0
    svg: "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='#FFD700' 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 updated successfully
{
  "data": {
    "updateUserTier": {
      "level": 1,
      "name": "Elite Bronze",
      "point": 1000,
      "svg": "<svg>...</svg>"
    }
  }
}

Use Cases

โš–๏ธ
Rebalancing

Adjust point thresholds based on user progression data and engagement metrics

๐ŸŽจ
Visual Refresh

Update badge designs to match new branding or seasonal themes

๐Ÿท๏ธ
Rebranding

Rename tiers to better reflect platform identity or user feedback

๐Ÿ”ง
Bug Fixes

Correct typos or fix improperly configured tier settings

Best Practices

๐Ÿ“ข
Communicate Changes

Notify users before making significant point requirement changes that might affect their current tier status

๐ŸŽฏ
Preserve Progression Logic

Ensure updated point values maintain proper progression order (tier N+1 should always require more points than tier N)

๐Ÿงช
Test Visual Changes

Validate SVG badges render correctly across all platforms before deploying updates

๐Ÿ“Š
Data-Driven Adjustments

Use analytics to inform point threshold changes - adjust based on actual user distribution and engagement patterns

๐Ÿ”„
Partial Updates

Only include fields you want to change - omitted fields will retain their current values

Implementation Example

๐Ÿ’ป
Admin Implementation
Update tiers with validation
// Fetch current tier configuration
const { data: currentTiers } = await client.query({
  query: gql`
    query GetTiers {
      getUserTiers {
        level
        name
        point
      }
    }
  `
});

// Validate new point value
const validatePointUpdate = (level: number, newPoint: number) => {
  const sortedTiers = currentTiers.getUserTiers.sort(
    (a, b) => a.level - b.level
  );

  const prevTier = sortedTiers.find(t => t.level === level - 1);
  const nextTier = sortedTiers.find(t => t.level === level + 1);

  if (prevTier && newPoint <= prevTier.point) {
    throw new Error(`Point value must be greater than ${prevTier.name} (${prevTier.point})`);
  }

  if (nextTier && newPoint >= nextTier.point) {
    throw new Error(`Point value must be less than ${nextTier.name} (${nextTier.point})`);
  }

  return true;
};

// Update tier with validation
try {
  validatePointUpdate(2, 6000);

  const { data } = await client.mutate({
    mutation: gql`
      mutation UpdateTier($level: Int!, $point: Float) {
        updateUserTier(level: $level, point: $point) {
          level
          name
          point
        }
      }
    `,
    variables: {
      level: 2,
      point: 6000
    }
  });

  console.log(`Updated tier: ${data.updateUserTier.name} to ${data.updateUserTier.point} points`);
} catch (error) {
  console.error('Update failed:', error.message);
}

Impact Considerations

โšก
User Impact
Consider these effects before updating
Point Threshold Increases

Users currently at this tier may drop to a lower tier if they don't meet the new requirement

Point Threshold Decreases

More users may become eligible for this tier, potentially reducing its prestige

Name Changes

Update all UI references and user communications to reflect new tier names

Badge Updates

Users will see new badges immediately - ensure designs are production-ready

System-Wide Changes

Updates to tier configurations affect all users at that tier level. Plan changes carefully and communicate with your user base.