1+ import { Options } from './../../OptionsType' ;
12import {
23 SchemaComposer ,
34 getFlatProjectionFromAST ,
@@ -16,7 +17,10 @@ type Generator = (
1617 fieldConfig : ObjectTypeComposerFieldConfigAsObjectDefinition < any , any >
1718) => ObjectTypeComposerFieldConfigAsObjectDefinition < any , any > ;
1819
19- export function createGenerateHelper ( schemaComposer : SchemaComposer < any > ) : Generator {
20+ export function createGenerateHelper (
21+ schemaComposer : SchemaComposer < any > ,
22+ opts : Options
23+ ) : Generator {
2024 return function generateMutation (
2125 fieldConfig : ObjectTypeComposerFieldConfigAsObjectDefinition < any , any >
2226 ) : ObjectTypeComposerFieldConfigAsObjectDefinition < any , any > {
@@ -27,10 +31,10 @@ export function createGenerateHelper(schemaComposer: SchemaComposer<any>): Gener
2731 }
2832
2933 fieldConfig . type . addFields ( {
30- status : getMutationStatusEnumTC ( schemaComposer ) ,
34+ status : getMutationStatusEnumTC ( schemaComposer , opts ) ,
3135 query : 'Query!' ,
3236 error : 'String' ,
33- errorCode : getMutationErrorCodeEnumTC ( schemaComposer ) ,
37+ errorCode : getMutationErrorCodeEnumTC ( schemaComposer , opts ) ,
3438 } ) ;
3539
3640 const subResolve = fieldConfig . resolve || ( ( ) => ( { } ) ) ;
@@ -61,8 +65,10 @@ export function createGenerateHelper(schemaComposer: SchemaComposer<any>): Gener
6165 } ;
6266}
6367
64- function getMutationErrorCodeEnumTC ( sc : SchemaComposer < any > ) {
65- return sc . getOrCreateETC ( 'MutationErrorCodeEnum' , ( etc ) => {
68+ function getMutationErrorCodeEnumTC ( sc : SchemaComposer < any > , opts : Options ) {
69+ const { typePrefix } = opts ;
70+
71+ return sc . getOrCreateETC ( `${ typePrefix } MutationErrorCodeEnum` , ( etc ) => {
6672 etc . addFields ( {
6773 QUEUE_NOT_FOUND : { value : ErrorCodeEnum . QUEUE_NOT_FOUND } ,
6874 JOB_NOT_FOUND : { value : ErrorCodeEnum . JOB_NOT_FOUND } ,
@@ -71,8 +77,10 @@ function getMutationErrorCodeEnumTC(sc: SchemaComposer<any>) {
7177 } ) ;
7278}
7379
74- function getMutationStatusEnumTC ( sc : SchemaComposer < any > ) {
75- return sc . getOrCreateETC ( 'MutationStatusEnum' , ( etc ) => {
80+ function getMutationStatusEnumTC ( sc : SchemaComposer < any > , opts : Options ) {
81+ const { typePrefix } = opts ;
82+
83+ return sc . getOrCreateETC ( `${ typePrefix } MutationStatusEnum` , ( etc ) => {
7684 etc . addFields ( {
7785 OK : { value : MutationStatusEnum . OK } ,
7886 ERROR : { value : MutationStatusEnum . ERROR } ,
0 commit comments