File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -52,10 +52,16 @@ export const serverSchemas = {
5252 const directiveSchemas = nitro . graphql . directiveSchemas
5353
5454 if ( ! schemas . length && ! directiveSchemas ) {
55+ // Return demo schema when no schemas found
5556 if ( nitro . options . dev ) {
56- nitro . logger . warn ( ' [nitro-graphql] No schemas found. Virtual module will export empty array.' )
57+ nitro . logger . warn ( ` [nitro-graphql] No schemas found. Using demo schema. Add .graphql files to ${ nitro . graphql . serverDir } ` )
5758 }
58- return 'export const schemas = []'
59+ return `export const schemas = [
60+ { def: \`type Query {
61+ hello: String!
62+ }
63+ \` }
64+ ]`
5965 }
6066
6167 const importStatements = schemas . map ( s => `import ${ getImportId ( s ) } from '${ s } ';` )
@@ -77,10 +83,13 @@ export const serverResolvers = {
7783 const imports = [ ...nitro . scanResolvers ]
7884
7985 if ( ! imports . length ) {
86+ // Return demo resolver when no resolvers found
8087 if ( nitro . options . dev ) {
81- nitro . logger . warn ( ' [nitro-graphql] No resolvers found. Virtual module will export empty array.' )
88+ nitro . logger . warn ( ` [nitro-graphql] No resolvers found. Using demo resolver. Add .resolver.ts files to ${ nitro . graphql . serverDir } ` )
8289 }
83- return 'export const resolvers = []'
90+ return `export const resolvers = [
91+ { resolver: { Query: { hello: () => 'Hello from nitro-graphql!' } } }
92+ ]`
8493 }
8594
8695 return generateImportModule ( imports , 'resolvers' , 'resolver' )
You can’t perform that action at this time.
0 commit comments