Member Junction
    Preparing search index...

    Function sanitizeGraphQLName

    • Sanitizes a string to be a valid GraphQL name component, preserving original capitalization. GraphQL names must match the pattern [_A-Za-z][_0-9A-Za-z]* and cannot start with double underscore

      Parameters

      • input: string

        The string to sanitize

      Returns string

      A valid GraphQL name component with special characters removed

      // Input: Schema name with special characters
      sanitizeGraphQLName("my-schema")
      // Output: "myschema"
      // Input: Name starting with double underscore (reserved)
      sanitizeGraphQLName("__mj_User")
      // Output: "mjUser"
      // (Removes __ prefix and underscores)
      // Input: Name starting with a digit
      sanitizeGraphQLName("123Orders")
      // Output: "_123Orders"
      // (Prepends underscore since GraphQL names can't start with digits)
      // Input: Preserves capitalization
      sanitizeGraphQLName("MyTable_Name")
      // Output: "MyTableName"
      // (Removes underscores but preserves case)
      // Input: Empty or invalid input
      sanitizeGraphQLName("")
      // Output: ""

      sanitizeGraphQLName("!!!###")
      // Output: "_"
      // (All chars removed, so prepends underscore)