Minor Changes
-
#5478
24d81ca854
Thanks @alicanerdurmaz! - feat: addgqlQuery
andgqlMutation
support. #5489Previously,
@refinedev/hasura
package only supported GraphQL operations throughmeta.fields
.Now we've added
gqlQuery
andgqlMutation
fields inmeta
object.You can utilize these fields along with
graphql-tag
package to build your queries/mutations.See the updated documentation for more information: https://refine.dev/docs/data/packages/hasura/
Query Example:
import { useList } from "@refinedev/core"; import gql from "graphql-tag"; const PRODUCTS_QUERY = gql` query ProductsList( $offset: Int! $limit: Int! $order_by: [products_order_by!] where: $where ) { products(offset: $paging, limit: $filter, order_by: $order_by, where: $where) { id name } categories_aggregate(where: $where) { aggregate { count } } } `; const { data } = useList({ resource: "products", meta: { gqlQuery: PRODUCTS_QUERY }, });
Mutation Example:
import { useForm } from "@refinedev/core"; import gql from "graphql-tag"; const CREATE_PRODUCT_MUTATION = gql` mutation CreateProduct($object: posts_insert_input!) { createOneProduct(object: $object) { id name } } `; const { formProps } = useForm({ resource: "products", meta: { gqlMutation: CREATE_PRODUCT_MUTATION }, });