11import { createReactClient } from '@gqty/react' ;
2- import { NhostClient } from '@nhost/nextjs ' ;
2+ import { createClient as createNhostClient } from '@nhost/nhost-js ' ;
33import type { QueryFetcher } from 'gqty' ;
44import { Cache , createClient } from 'gqty' ;
55import { createClient as createSubscriptionsClient } from 'graphql-ws' ;
66import type { GeneratedSchema } from './schema.generated' ;
77import { generatedSchema , scalarsEnumsHash } from './schema.generated' ;
88
9- const nhost = new NhostClient ( {
9+ const nhost = createNhostClient ( {
1010 subdomain : process . env . NEXT_PUBLIC_NHOST_SUBDOMAIN ,
1111 region : process . env . NEXT_PUBLIC_NHOST_REGION ,
1212} ) ;
@@ -17,15 +17,15 @@ const getHeaders = (): Record<string, string> =>
1717 'Content-Type' : 'application/json' ,
1818 'x-hasura-admin-secret' : process . env . HASURA_GRAPHQL_ADMIN_SECRET ,
1919 }
20- : nhost . auth . isAuthenticated ( )
21- ? {
22- 'Content-Type' : 'application/json' ,
23- authorization : `Bearer ${ nhost . auth . getAccessToken ( ) } ` ,
24- }
25- : {
26- 'Content-Type' : 'application/json' ,
27- 'x-hasura-role' : 'public' ,
28- } ;
20+ : nhost . getUserSession ( )
21+ ? {
22+ 'Content-Type' : 'application/json' ,
23+ authorization : `Bearer ${ nhost . getUserSession ( ) ?. accessToken } ` ,
24+ }
25+ : {
26+ 'Content-Type' : 'application/json' ,
27+ 'x-hasura-role' : 'public' ,
28+ } ;
2929
3030const url = `https://${ process . env . NEXT_PUBLIC_NHOST_SUBDOMAIN } .hasura.${ process . env . NEXT_PUBLIC_NHOST_REGION } .nhost.run/v1/graphql` ;
3131
0 commit comments