Skip to content

Commit

Permalink
fix: change OperationTypeNode to enum
Browse files Browse the repository at this point in the history
Changes OperationTypeNode to enum instead of a union type.
This allows developers to use the type as `OperationTypeNode.QUERY`
instead of risking to msispell the string 'query'.

Example:

Instead of having to write

`operation === 'query'`

you can instead write

`operation === OperationTypeNode.QUERY`
  • Loading branch information
lekoaf committed Oct 12, 2021
1 parent 82900fa commit 85a1fee
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/language/ast.ts
Expand Up @@ -364,7 +364,11 @@ export interface OperationDefinitionNode {
readonly selectionSet: SelectionSetNode;
}

export type OperationTypeNode = 'query' | 'mutation' | 'subscription';
export enum OperationTypeNode {
QUERY = 'query',
MUTATION = 'mutation',
SUBSCRIPTION = 'subscription'
}

export interface VariableDefinitionNode {
readonly kind: 'VariableDefinition';
Expand Down

0 comments on commit 85a1fee

Please sign in to comment.