NYYU Logo
APIUser Tier

Delete User Tier

Remove a tier level from the gamification system (Admin only)

๐Ÿ—‘๏ธ

Delete User Tier

ADMIN

Remove tier levels from the progression system

Destructive Operation

This mutation permanently removes a tier level. This operation cannot be undone and may affect users currently at this tier.

Overview

The deleteUserTier mutation allows administrators to remove tier levels from the gamification system. Use with extreme caution as this operation is irreversible and impacts user progression structure.

GraphQL Schema

โš ๏ธ
Mutation Definition
Permanently removes a tier by level
deleteUserTier(
  level: Int!
): Int

Parameters

๐Ÿ“
Required Parameter
Specify the tier to delete
level
Tier LevelInt!Required

The unique level identifier of the tier to delete (e.g., 1, 2, 3).

Return Type

๐Ÿ“ฆ
Deleted Level
Returns the level of the deleted tier
Int

Returns: The integer value of the deleted tier's level on success.

Example Mutation

mutation {
  deleteUserTier(level: 1)
}

Example Response

โœ…
Success Response
Tier deleted successfully
{
  "data": {
    "deleteUserTier": 1
  }
}

Critical Warnings

๐Ÿšจ
Before Deletion
Review these critical considerations
โ›”
Irreversible Action

Deleted tiers cannot be recovered. All tier configuration data is permanently lost.

๐Ÿ‘ฅ
User Impact

Users currently at this tier will need to be reassigned or may lose tier status.

๐Ÿ”—
Progression Gaps

Deleting middle tiers creates gaps in the progression ladder (e.g., levels 1, 2, 4, 5).

๐Ÿ’พ
No Backup

Export tier configuration before deletion if you may need to restore it later.

Safe Deletion Workflow

โœ…
Pre-Deletion Checklist
Follow these steps to minimize impact
1
Audit User Distribution

Check how many users are currently at the tier level you plan to delete

2
Export Configuration

Save tier details (name, points, SVG) in case you need to recreate it

3
Notify Affected Users

Inform users at this tier about the upcoming change and what it means for them

4
Plan User Migration

Decide how users will be reassigned to remaining tiers (nearest lower tier, manual assignment, etc.)

5
Execute Deletion

Perform the deletion during low-traffic periods to minimize user disruption

6
Verify System Integrity

Confirm all users are properly assigned to valid tiers and progression logic still works

Use Cases

๐Ÿ”„
System Simplification

Remove excessive tiers to streamline progression and reduce complexity

๐Ÿงช
Testing Cleanup

Remove test or experimental tiers that are no longer needed

โ™ป๏ธ
Tier Restructuring

Delete obsolete tiers when completely redesigning the progression system

๐ŸŽฏ
Event Conclusion

Remove limited-time special tiers after promotional events end

Implementation Example

๐Ÿ’ป
Safe Deletion Implementation
With validation and backup
// Step 1: Fetch and backup tier configuration
const { data: tiers } = await client.query({
  query: gql`
    query GetTiers {
      getUserTiers {
        level
        name
        point
        svg
      }
    }
  `
});

const tierToDelete = tiers.getUserTiers.find(t => t.level === 1);

// Create backup
const backup = {
  ...tierToDelete,
  deletedAt: new Date().toISOString()
};
console.log('Tier backup:', JSON.stringify(backup, null, 2));

// Step 2: Validate deletion won't break progression
const validateDeletion = (level: number) => {
  const sortedTiers = tiers.getUserTiers.sort((a, b) => a.level - b.level);
  const tierIndex = sortedTiers.findIndex(t => t.level === level);

  // Don't allow deleting first or last tier
  if (tierIndex === 0) {
    throw new Error('Cannot delete the lowest tier - users need a baseline tier');
  }

  if (tierIndex === sortedTiers.length - 1) {
    throw new Error('Cannot delete the highest tier - maintain progression cap');
  }

  return true;
};

// Step 3: Execute deletion with confirmation
try {
  validateDeletion(1);

  const confirmDelete = confirm(
    `โš ๏ธ Delete tier "${tierToDelete.name}" (Level ${tierToDelete.level})?\n\n` +
    `This action cannot be undone.\n\n` +
    `Click OK to proceed with deletion.`
  );

  if (!confirmDelete) {
    console.log('Deletion cancelled by admin');
    return;
  }

  const { data } = await client.mutate({
    mutation: gql`
      mutation DeleteTier($level: Int!) {
        deleteUserTier(level: $level)
      }
    `,
    variables: {
      level: 1
    }
  });

  console.log(`Successfully deleted tier level ${data.deleteUserTier}`);
  console.log('Backup available:', backup);

} catch (error) {
  console.error('Deletion failed:', error.message);
}

Alternative: Disable Instead of Delete

๐Ÿ’ก
Safer Alternative
Consider these reversible options
Extremely High Point Threshold

Set the tier's point requirement to an unreachable value (e.g., 999999999) to effectively disable it

Hidden Status Flag

If your system supports it, use a 'hidden' or 'disabled' flag instead of deletion

Application-Level Filtering

Filter out specific tiers in your application code rather than removing from database

Permanent Deletion

This operation is irreversible. Always create backups and notify affected users before deleting tier levels. Consider using updateUserTier to disable tiers instead of deletion.