@okam/directus-query 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/index.mjs +2 -2
- package/lib/init.d.ts +2 -2
- package/package.json +1 -1
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@tanstack/react-query"),l=require("radash"),a=require("graphql-request"),y=process.env.NEXT_PUBLIC_GRAPHQL_URL,q=process.env.NEXT_GRAPHQL_URL_ADMIN,Q=process.env.NEXT_PUBLIC_API_TOKEN,_=process.env.NEXT_PUBLIC_API_TOKEN,A=new a.GraphQLClient(y,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${Q}`}}),N=new a.GraphQLClient(q,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${_}`}});new t.QueryClient({queryCache:new t.QueryCache({onError:e=>{console.error(e)}}),defaultOptions:{queries:{staleTime:5*1e3}}});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@tanstack/react-query"),l=require("radash"),a=require("graphql-request"),y=process.env.NEXT_PUBLIC_GRAPHQL_URL,q=process.env.NEXT_GRAPHQL_URL_ADMIN,Q=process.env.NEXT_PUBLIC_API_TOKEN??"",_=process.env.NEXT_PUBLIC_API_TOKEN,A=new a.GraphQLClient(y,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${Q}`}}),N=new a.GraphQLClient(q,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${_}`}});new t.QueryClient({queryCache:new t.QueryCache({onError:e=>{console.error(e)}}),defaultOptions:{queries:{staleTime:5*1e3}}});function c(e,r,n=A){return n.request(e,{...r})}function o(e,r){return[l.get(e,"definitions.0.name.value"),r]}function p(e,r,n,s){const u=o(e,r);return t.useQuery({queryKey:u,queryFn:async({queryKey:i})=>c(e,i[1],s),...n})}function T(e,r,n){const s=o(e,r);return t.useSuspenseQuery({queryKey:s,queryFn:async({queryKey:u})=>c(e,u[1]),...n})}function G(e,r,n){const s=o(e,r);return t.useSuspenseQuery({queryKey:s,queryFn:async({queryKey:u})=>c(e,u[1],N),...n})}const d=process.env.NEXT_PUBLIC_GRAPHQL_URL,h=process.env.NEXT_PUBLIC_API_TOKEN,P={credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${h}`}},L=(e=d,r=P)=>{const n=new a.GraphQLClient(e,r);function s(u,i){return c(u,i,n)}return{queryGql:s,client:n}};exports.getQueryValues=o;exports.initDirectusQuery=L;exports.queryGql=c;exports.useGqlQuery=p;exports.useSuspenseGqlQuery=T;exports.useSuspenseGqlQueryAdmin=G;
|
package/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QueryClient as l, QueryCache as _, useQuery as y, useSuspenseQuery as a } from "@tanstack/react-query";
|
|
2
2
|
import { get as q } from "radash";
|
|
3
3
|
import { GraphQLClient as c } from "graphql-request";
|
|
4
|
-
const N = process.env.NEXT_PUBLIC_GRAPHQL_URL, A = process.env.NEXT_GRAPHQL_URL_ADMIN, T = process.env.NEXT_PUBLIC_API_TOKEN, p = process.env.NEXT_PUBLIC_API_TOKEN, P = new c(N, {
|
|
4
|
+
const N = process.env.NEXT_PUBLIC_GRAPHQL_URL, A = process.env.NEXT_GRAPHQL_URL_ADMIN, T = process.env.NEXT_PUBLIC_API_TOKEN ?? "", p = process.env.NEXT_PUBLIC_API_TOKEN, P = new c(N, {
|
|
5
5
|
credentials: "include",
|
|
6
6
|
mode: "cors",
|
|
7
7
|
fetch,
|
|
@@ -79,7 +79,7 @@ const f = process.env.NEXT_PUBLIC_GRAPHQL_URL, E = process.env.NEXT_PUBLIC_API_T
|
|
|
79
79
|
};
|
|
80
80
|
export {
|
|
81
81
|
i as getQueryValues,
|
|
82
|
-
R as
|
|
82
|
+
R as initDirectusQuery,
|
|
83
83
|
u as queryGql,
|
|
84
84
|
G as useGqlQuery,
|
|
85
85
|
v as useSuspenseGqlQuery,
|
package/lib/init.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { type TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
|
2
2
|
import { GraphQLClient } from 'graphql-request';
|
|
3
3
|
import type { Variables } from 'graphql-request';
|
|
4
4
|
import type { RequestConfig } from 'graphql-request/build/esm/types';
|
|
5
|
-
declare const
|
|
5
|
+
declare const initDirectusQuery: (graphqlEndPoint?: string, requestConfig?: RequestConfig) => {
|
|
6
6
|
queryGql: <TResult, TVariables extends Variables>(document: TypedDocumentNode<TResult, TVariables>, queryKey?: TVariables | undefined) => Promise<TResult>;
|
|
7
7
|
client: GraphQLClient;
|
|
8
8
|
};
|
|
9
|
-
export default
|
|
9
|
+
export default initDirectusQuery;
|