![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
hql-tag
is a Hasura specific wrapper over graphql-tag
. In Hasura GraphQL backend, we can query data with arguments directly without adding to backend schema using where
argument and sort data using order_by
argument. However, in a real-world query involving multiple where
conditions on multiple arguments, the queries are not that readable.
hql-tag
solves this issue by providing shorthand way of writing where
and order_by
arguments.
DEMO - Link to codesandbox to compare and play around with graphql-tag
& hql-tag
Note: This library works fine with all the GraphQL Client frameworks that works with
graphql-tag
.
Install the dependencies. Please note, graphql
& graphql-tag
are peerDependencies
yarn add graphql graphql-tag hql-tag
or
npm i graphql graphql-tag hql-tag
Imagine a clumsy query as below:
import gql from 'graphql-tag';
const clumsyHasuraQuery = gql`
query getProductById($id: Int!) {
product(
limit: 10
offset: 10
where: { id: { _eq: $id }, quantity: { _gte: 10 }, type_id: { _eq: 10, _gte: 22, _lte: 5, _in: [72,73,74] } }
order_by: {category: asc, description: desc}
) {
category
id
}
}
`;
The above query can be made more readable and elegant using hql-tag
as below:
Note: It is recommended to import
hql-tag
asgql
to get syntax highlighting and linting support from vscode extensions
import gql from 'hql-tag';
const elegantHasuraQuery = gql`
query getProductById($id: Int!) {
product(
limit: 10
offset: 10
id_eq: $id
quantity_gte: 10
type_id_eq: 10
type_id_gte: 22
type_id_lte: 5
type_id_in: [72, 73, 74]
category_ord: asc
description_order: desc
) {
category
id
}
}
`;
gql
from hql-tag
instead of graphql-tag
where
and order_by
argumentswhere
condition, add argument in the following format: ${argumentField}_${whereOperator}
.[ "eq", "gte", "gt", "ilike", "in", "like", "lt", "lte", "neq", "nilike", "nin", "nlike", "similar", "nsimilar" ]
.order_by
condition, add argument in the following format: ${argumentField}_${orderByOperator}
ord
(short form) or order
.The creator of the library is always open to discussions/suggestions. Vilva Athiban Twitter
FAQs
A Hasura specific wrapper on graphql-tag for writing elegant queries
The npm package hql-tag receives a total of 1 weekly downloads. As such, hql-tag popularity was classified as not popular.
We found that hql-tag demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.