diff --git a/playground/nuxt.config.ts b/playground/nuxt.config.ts
index 7fee56a..485b9c8 100644
--- a/playground/nuxt.config.ts
+++ b/playground/nuxt.config.ts
@@ -16,10 +16,11 @@ export default defineNuxtConfig({
frontendUrl: 'https://demo.wpnuxt.com',
faustSecretKey: '',
showBlockInfo: false,
- debug: false
+ debug: false,
+ replaceSchema: true
},
graphqlMiddleware: {
- downloadSchema: false,
+ downloadSchema: true,
},
ui: {
icons: ['heroicons', 'uil', 'mdi']
diff --git a/playground/pages/[...slug].vue b/playground/pages/[...slug].vue
index e0cb8f7..d158541 100644
--- a/playground/pages/[...slug].vue
+++ b/playground/pages/[...slug].vue
@@ -44,9 +44,13 @@ if (post?.data?.title) {
/>
- published:
+ published:
{{ post.data.date.split('T')[0] }}
+
+ meta:
+ {{ post.data.seo.metaDesc }}
+
({
faustSecretKey: '',
defaultMenuName: 'main',
showBlockInfo: false,
- debug: false
+ debug: false,
+ replaceSchema: false
},
async setup (options, nuxt) {
nuxt.options.runtimeConfig.public.wpNuxt = defu(nuxt.options.runtimeConfig.public.wpNuxt, {
@@ -29,7 +30,8 @@ export default defineNuxtModule({
frontendUrl: process.env.WPNUXT_FRONTEND_URL ? process.env.WPNUXT_FRONTEND_URL : options.frontendUrl!,
defaultMenuName: process.env.WPNUXT_DEFAULT_MENU_NAME ? process.env.WPNUXT_DEFAULT_MENU_NAME : options.defaultMenuName!,
showBlockInfo: process.env.WPNUXT_SHOW_BLOCK_INFO ? process.env.WPNUXT_SHOW_BLOCK_INFO === 'true' : options.showBlockInfo!,
- debug: process.env.WPNUXT_DEBUG ? process.env.WPNUXT_DEBUG === 'true' : options.debug!
+ debug: process.env.WPNUXT_DEBUG ? process.env.WPNUXT_DEBUG === 'true' : options.debug!,
+ replaceSchema: process.env.WPNUXT_REPLACE_SCHEMA ? process.env.WPNUXT_REPLACE_SCHEMA === 'true' : options.replaceSchema!
})
// we're not putting the secret in public config, so it goes into runtimeConfig
nuxt.options.runtimeConfig.wpNuxt = defu(nuxt.options.runtimeConfig.wpNuxt, {
@@ -137,9 +139,14 @@ export default defineNuxtModule({
.replace(/^(~~|@@)/, nuxt.options.rootDir)
.replace(/^(~|@)/, nuxt.options.srcDir)
const userQueryPathExists = existsSync(userQueryPath)
- const queryPaths = userQueryPathExists
- ? [ resolver.resolve(userQueryPath + '**/*.gql'), resolver.resolve('./runtime/queries/**/*.gql')]
- : [ resolver.resolve('./runtime/queries/**/*.gql')]
+ let queryPaths
+ if (userQueryPathExists && options.replaceSchema) {
+ queryPaths = [ resolver.resolve(userQueryPath + '**/*.gql')]
+ } else if (userQueryPathExists && !options.replaceSchema) {
+ queryPaths = [ resolver.resolve(userQueryPath + '**/*.gql'), resolver.resolve('./runtime/queries/**/*.gql')]
+ } else {
+ queryPaths = [ resolver.resolve('./runtime/queries/**/*.gql')]
+ }
logger.debug('Loading query paths:', queryPaths)
await installModule('nuxt-graphql-middleware', {
@@ -213,6 +220,7 @@ declare module '@nuxt/schema' {
defaultMenuName?: string
showBlockInfo?: boolean
debug?: boolean
+ replaceSchema?: boolean
}
}
@@ -229,6 +237,7 @@ declare module '@nuxt/schema' {
defaultMenuName?: string
showBlockInfo?: boolean
debug?: boolean
+ replaceSchema?: boolean
}
}
}
diff --git a/src/types.ts b/src/types.ts
index ff895b0..07b2a43 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -6,4 +6,5 @@ export interface ModuleOptions {
defaultMenuName?: string
showBlockInfo?: boolean
debug?: boolean
+ replaceSchema?: boolean
}