Docs@skmtc/core

Operations

FUNCTION

toEndpointType

@skmtc/core 0.63.4

Determines the endpoint type based on HTTP method.

Signature

import { toEndpointType } from '@skmtc/core'

toEndpointType(operation: OasOperation): 'query' | 'mutation'

Parameters

operation, OasOperation required

The OpenAPI operation to analyze

Example
const getOp = new OasOperation({ method: 'get', path: '/users' });
console.log(toEndpointType(getOp)); // 'query'

const postOp = new OasOperation({ method: 'post', path: '/users' });
console.log(toEndpointType(postOp)); // 'mutation'

Returns

'query' | 'mutation'

'query' for GET and QUERY operations, 'mutation' for all others