1
1
import { readFileSync } from 'fs' ;
2
2
import { buildSchema , printSchema } from 'graphql' ;
3
- import { GraphbackCoreMetadata } from '@graphback/core' ;
3
+ import { GraphbackCoreMetadata , GraphbackPluginEngine } from '@graphback/core' ;
4
4
import { SchemaCRUDPlugin } from "@graphback/codegen-schema" ;
5
5
import { DataSyncPlugin } from '../src/DataSyncPlugin' ;
6
6
@@ -18,7 +18,7 @@ test('Test snapshot config gql', async () => {
18
18
"subDelete" : true
19
19
}
20
20
21
- const schemaPlugin = new SchemaCRUDPlugin ( ) ;
21
+ const schemaPlugin = new SchemaCRUDPlugin ( ) ;
22
22
const datasync = new DataSyncPlugin ( )
23
23
const metadata = new GraphbackCoreMetadata ( {
24
24
crudMethods : defautConfig
@@ -42,7 +42,7 @@ it('uses existing GraphbackTimestamp scalars', async () => {
42
42
"subDelete" : true
43
43
}
44
44
45
- const schemaPlugin = new SchemaCRUDPlugin ( ) ;
45
+ const schemaPlugin = new SchemaCRUDPlugin ( ) ;
46
46
const datasync = new DataSyncPlugin ( )
47
47
const metadata = new GraphbackCoreMetadata ( {
48
48
crudMethods : defautConfig
@@ -80,7 +80,7 @@ it('adds version when conflicts are enabled', async () => {
80
80
"subDelete" : true
81
81
}
82
82
83
- const schemaPlugin = new SchemaCRUDPlugin ( ) ;
83
+ const schemaPlugin = new SchemaCRUDPlugin ( ) ;
84
84
const datasync = new DataSyncPlugin ( { conflictConfig : { enabled : true } } )
85
85
const metadata = new GraphbackCoreMetadata ( {
86
86
crudMethods : defautConfig
@@ -105,3 +105,40 @@ it('adds version when conflicts are enabled', async () => {
105
105
const schema = datasync . transformSchema ( metadata )
106
106
expect ( printSchema ( schema ) ) . toMatchSnapshot ( ) ;
107
107
} ) ;
108
+
109
+ test ( 'When all CRUD flags are disabled, resolvers and root schema types are not generated' , ( ) => {
110
+ const model = buildSchema ( `
111
+ """@model"""
112
+ type Note {
113
+ id: ID!
114
+ title: String
115
+ }` )
116
+
117
+ const pluginEngine = new GraphbackPluginEngine ( {
118
+ schema : model ,
119
+ plugins : [
120
+ new DataSyncPlugin ( )
121
+ ] ,
122
+ config : {
123
+ crudMethods : {
124
+ find : false ,
125
+ findOne : false ,
126
+ create : false ,
127
+ update : false ,
128
+ delete : false ,
129
+ subCreate : false ,
130
+ subDelete : false ,
131
+ subUpdate : false
132
+ }
133
+ }
134
+ } ) ;
135
+
136
+ const metadata = pluginEngine . createResources ( ) ;
137
+ const schema = metadata . getSchema ( ) ;
138
+ const resolvers = metadata . getResolvers ( ) ;
139
+
140
+ expect ( resolvers ) . toBeUndefined ( )
141
+ expect ( schema . getQueryType ( ) ) . toBeUndefined ( ) ;
142
+ expect ( schema . getMutationType ( ) ) . toBeUndefined ( ) ;
143
+ expect ( schema . getSubscriptionType ( ) ) . toBeUndefined ( ) ;
144
+ } ) ;
0 commit comments