@authentified/retool-scripts
TypeScript icon, indicating that this package has built-in type declarations

0.14.0 • Public • Published

@authentified/retool-scripts

A collection of Retool scripts designed to make integrating with Gadget's APIs a lot easier.

Installation

Add the Authentified Retool scripts Unpkg URL to your Retool libraries.

https://unpkg.com/@authentified/retool-scripts

Install Authentified's retool scripts via Unpkg https://unpkg.com/@authentified/retool-scripts

If needed, you can also include via various package managers:

npm install @authentified/retool-scripts
yarn add @authentified/retool-scripts
pnpm add @authentified/retool-scripts

Functions

transformFilterStackToGraphQLFilter

This function translates a Retool table filter stack to Gadget's GraphQL Filters. Create a transformer also called transformFilterStackToGraphQLFilter and paste the following code.

return window.Authentified.transformFilterStackToGraphQLFilter(
  {{ myTable.filterStack }}
)

This Transformer can now be used to generate the filter argument for your GraphQL query.

You can also append an extra GraphQL filter as a second argument if you want to ensure particular filters are passed to a query. If the filter stack is empty, the extra parameter will be used as the default filter:

return window.Authentified.transformFilterStackToGraphQLFilter(
  {{ myTable.filterStack }},
  { status: { equals: "published" }}
)

Filtering on related models

To enable filtering on related models, you will need to change the ID of the column to a dot notation representation of the filter. For example if you have a reference to a model named product, and you want to search by a field called title you just change the ID of your column to product.title and transformFilterStackToGraphQLFilter will do the rest.

Related model filtering

transformSortArrayToGraphQLSortOrder

This function translates a Retool sort array to Gadget's GraphQL SortOrder. Create a transformer also called transformSortArrayToGraphQLSortOrder and paste the following code.

return window.Authentified.transformSortArrayToGraphQLSortOrder(
  {{ listingsTable.sortArray }}
)

You can also prepend an additional SortBy object it you want to ensure a particular default SortBy is passed to a query:

return window.Authentified.transformSortArrayToGraphQLSortOrder(
  {{ listingsTable.sortArray }},
  { createdAt: "Descending" },
)

Example with Retool GraphQL query

Use with GraphQL Query

Readme

Keywords

none

Package Sidebar

Install

npm i @authentified/retool-scripts

Weekly Downloads

6

Version

0.14.0

License

SEE LICENSE IN LICENSE.md

Unpacked Size

26.9 kB

Total Files

14

Last publish

Collaborators

  • authentified-admin