talawa-api / Exports / utilities/graphQLConnection/transformToDefaultGraphQLConnection
Module: utilities/graphQLConnection/transformToDefaultGraphQLConnection
Table of contents
Type Aliases
Functions
Type Aliases
CreateCursor
Ƭ CreateCursor<T0
>: (object
: T0
) => string
This is typescript type of the callback function createCursor
.
Type parameters
Name |
---|
T0 |
Type declaration
▸ (object
): string
Parameters
Name | Type |
---|---|
object | T0 |
Returns
string
Defined in
src/utilities/graphQLConnection/transformToDefaultGraphQLConnection.ts:11
CreateNode
Ƭ CreateNode<T0
, T1
>: (object
: T0
) => T1
This is typescript type of the callback function createNode
.
Type parameters
Name |
---|
T0 |
T1 |
Type declaration
▸ (object
): T1
Parameters
Name | Type |
---|---|
object | T0 |
Returns
T1
Defined in
src/utilities/graphQLConnection/transformToDefaultGraphQLConnection.ts:16
TransformToDefaultGraphQLConnectionArguments
Ƭ TransformToDefaultGraphQLConnectionArguments<T0
, T1
, T2
>: Object
Type parameters
Name |
---|
T0 |
T1 |
T2 |
Type declaration
Name | Type |
---|---|
createCursor? | CreateCursor <T1 > |
createNode? | CreateNode <T1 , T2 > |
objectList | T1 [] |
parsedArgs | ParsedGraphQLConnectionArguments <T0 > |
totalCount | number |
Defined in
src/utilities/graphQLConnection/transformToDefaultGraphQLConnection.ts:18
Functions
transformToDefaultGraphQLConnection
▸ transformToDefaultGraphQLConnection<T0
, T1
, T2
>(«destructured»
): DefaultGraphQLConnection
<T2
>
This function is used to transform a list of objects to a standard graphQL connection object.
Type parameters
Name | Type |
---|---|
T0 | T0 |
T1 | extends Object |
T2 | T2 |
Parameters
Name | Type |
---|---|
«destructured» | TransformToDefaultGraphQLConnectionArguments <T0 , T1 , T2 > |
Returns
Remarks
The logic used in this function is common to almost all graphQL connection creation flows, abstracting that away into this function lets developers use a declarative way to create the graphQL connection object they want and prevents code duplication.
Example
const [objectList, totalCount] = await Promise.all([
User.find(filter)
.sort(sort)
.limit(limit)
.exec(),
User.find(filter)
.countDocuments()
.exec(),
]);
return transformToDefaultGraphQLConnection\<
String,
DatabaseUser,
DatabaseUser
\>(\{
objectList,
parsedArgs,
totalCount,
\});
Defined in
src/utilities/graphQLConnection/transformToDefaultGraphQLConnection.ts:53