Skip to main content

talawa-api / Exports / utilities/graphQLConnection/parseGraphQLConnectionArguments

Module: utilities/graphQLConnection/parseGraphQLConnectionArguments

Table of contents

Type Aliases

Functions

Type Aliases

ParseGraphQLConnectionArgumentsResult

Ƭ ParseGraphQLConnectionArgumentsResult<T0>: { errors: DefaultGraphQLArgumentError[] ; isSuccessful: false } | { isSuccessful: true ; parsedArgs: ParsedGraphQLConnectionArguments<T0> }

This is typescript type of the object returned from parseGraphQLConnectionArguments function.

Type parameters

Name
T0

Defined in

src/utilities/graphQLConnection/parseGraphQLConnectionArguments.ts:57


ParseGraphQLConnectionCursor

Ƭ ParseGraphQLConnectionCursor<T0>: (args: ParseGraphQLConnectionCursorArguments) => ParseGraphQLConnectionCursorResult<T0>

This is typescript type of the callback function parseCursor.

Type parameters

Name
T0

Type declaration

▸ (args): ParseGraphQLConnectionCursorResult<T0>

Parameters
NameType
argsParseGraphQLConnectionCursorArguments
Returns

ParseGraphQLConnectionCursorResult<T0>

Defined in

src/utilities/graphQLConnection/parseGraphQLConnectionArguments.ts:39


ParseGraphQLConnectionCursorArguments

Ƭ ParseGraphQLConnectionCursorArguments: Object

This is typescript type of the single object callback function parseCursor takes in as an argument.

Type declaration

NameType
cursorName"after" | "before"
cursorPathstring[]
cursorValuestring

Defined in

src/utilities/graphQLConnection/parseGraphQLConnectionArguments.ts:13


ParseGraphQLConnectionCursorResult

Ƭ ParseGraphQLConnectionCursorResult<T0>: Promise<{ errors: DefaultGraphQLArgumentError[] ; isSuccessful: false } | { isSuccessful: true ; parsedCursor: T0 }>

This is typescript type of object returned from the callback function parseCursor passed as an argument to parseGraphQLConnectionArguments, parseGraphQLConnectionArgumentsWithSortedBy, parseGraphQLConnectionArgumentsWithWhere and parseGraphQLConnectionArgumentsWithSortedByAndWhere functions.

Type parameters

Name
T0

Defined in

src/utilities/graphQLConnection/parseGraphQLConnectionArguments.ts:25


ParsedGraphQLConnectionArguments

Ƭ ParsedGraphQLConnectionArguments<T0>: Object

This is typescript type of the object containing the validated and transformed connection arguments passed to parseGraphQLConnectionArguments function.

Type parameters

Name
T0

Type declaration

NameType
cursorT0 | null
directionGraphQLConnectionTraversalDirection
limitnumber

Defined in

src/utilities/graphQLConnection/parseGraphQLConnectionArguments.ts:47

Functions

parseGraphQLConnectionArguments

parseGraphQLConnectionArguments<T0>(«destructured»): Promise<ParseGraphQLConnectionArgumentsResult<T0>>

This function handles validating and transforming arguments of a base graphQL connection.

Type parameters

Name
T0

Parameters

NameTypeDefault value
«destructured»Objectundefined
› argsDefaultGraphQLConnectionArgumentsundefined
› maximumLimit?numberMAXIMUM_FETCH_LIMIT
› parseCursorParseGraphQLConnectionCursor<T0>undefined

Returns

Promise<ParseGraphQLConnectionArgumentsResult<T0>>

Example

const result = await parseGraphQLConnectionArguments(\{
args: \{
after,
first,
\},
maximumLimit: 20,
parseCursor
\})
if (result.isSuccessful === false) \{
throw new GraphQLError("Invalid arguments provided.", \{
extensions: \{
code: "INVALID_ARGUMENTS",
errors: result.errors
\}
\})
\}
const \{ parsedArgs: \{ cursor, direction, limit \} \} = result;

Defined in

src/utilities/graphQLConnection/parseGraphQLConnectionArguments.ts:88