File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 3838 },
3939 "peerDependencies" : {
4040 "typescript" : " ^5" ,
41- "vite" : " ^6.0.0 " ,
42- "@urql/core" : " ^5.1.1 "
41+ "vite" : " >=6 " ,
42+ "@urql/core" : " >=5 "
4343 },
4444 "dependencies" : {
4545 "@types/fs-extra" : " ^11.0.4" ,
Original file line number Diff line number Diff line change @@ -131,10 +131,18 @@ export function drupal(options?: DrupalPluginOptions): Plugin {
131131 path . resolve ( process . cwd ( ) , "drupal-decoupled.config.ts" )
132132 ) ;
133133
134+ const importLine = hasCustomConfig
135+ ? `import customConfig from "./drupal-decoupled.config.ts";`
136+ : "" ;
137+
138+ const exchanges = hasCustomConfig
139+ ? "customConfig.exchanges ?? [fetchExchange]"
140+ : "[fetchExchange]" ;
141+
134142 const module = `
135143import { drupalAuthClient } from "drupal-auth-client";
136144import { Client, fetchExchange } from "@urql/core";
137- ${ hasCustomConfig ? `import customConfig from "./drupal-decoupled.config.ts";` : "" }
145+ ${ importLine }
138146
139147export async function getDrupalAuth() {
140148 return await drupalAuthClient("${ sanitizedDrupalUrl } ", {
@@ -147,7 +155,7 @@ export async function getDrupalClient() {
147155 const auth = await getDrupalAuth();
148156 return new Client({
149157 url: "${ fullGraphqlEndpoint } ",
150- exchanges: ${ hasCustomConfig ? "customConfig. exchanges ?? [fetchExchange]" : "[fetchExchange]" } ,
158+ exchanges: ${ exchanges } ,
151159 fetchOptions: {
152160 headers: {
153161 Authorization: \`\${auth.token_type} \${auth.access_token}\`,
@@ -162,3 +170,5 @@ export async function getDrupalClient() {
162170 } ,
163171 } ;
164172}
173+
174+ export type { DrupalViteConfig } from "./types" ;
Original file line number Diff line number Diff line change 11import type { Exchange } from "@urql/core" ;
22
3- export interface DrupalDecoupledConfig {
3+ export interface DrupalViteConfig {
44 /** Custom exchanges for the GraphQL client */
55 exchanges ?: Exchange [ ] ;
66}
You can’t perform that action at this time.
0 commit comments