graphql/utilities/validation
Functions
assertValidName()
Deprecated in v16Upholds the spec rules about naming. This helper is retained for backwards
compatibility; call assertName instead because assertValidName will be
removed in v17.
Signature:
assertValidName(name: string): string
Arguments
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name to validate. |
Returns
| Type | Description |
|---|---|
string | The validated GraphQL name. |
Example
import { assertValidName } from 'graphql/utilities';
const name = assertValidName('User');
// name: 'User'isValidNameError()
Deprecated in v16Returns an Error if a name is invalid. This helper is retained for backwards
compatibility; call assertName and catch the thrown GraphQLError instead
because isValidNameError will be removed in v17.
Signature:
isValidNameError(name: string): GraphQLError | undefined
Arguments
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name to validate. |
Returns
| Type | Description |
|---|---|
GraphQLError | undefined | A GraphQLError if the name is invalid; otherwise undefined. |
Example
import { isValidNameError } from 'graphql/utilities';
const error = isValidNameError('User');
// error: undefined