A convenient way to generate query strings for JSON:API.
yarn add @sosd/qs-constructor
import createQueryString from '@sosd/qs-constructor'
const queryString: string = createQueryString({ orderBy, language, id, where }: ResolverArgs, include: string | undefined)
-
interface ResolverArgs { language: string; id?: string | undefined; orderBy?: OrderBy | undefined; where?: Where[] | undefined; }
-
interface OrderBy { path: string; direction: OrderByDirection; }
-
interface Where { path: string; operator: WhereOperators; value: string; group?: string; }
-
type WhereOperators = | '=' | '<>' | '>' | '>=' | '<' | '<=' | 'STARTS_WITH' | 'CONTAINS' | 'ENDS_WITH' | 'IN' | 'NOT IN' | 'BETWEEN' | 'NOT BETWEEN' | 'IS NULL' | 'IS NOT NULL';
-
enum OrderByDirection { ASC = 'ASC', DSC = 'DSC', }