import camelCase from "lodash/camelCase" ; import pluralize from "pluralize" ; import { CREATE , DELETE , GET_LIST , GET_MANY , GET_MANY_REFERENCE , GET_ONE , UPDATE , } from "react-admin" ; import { Resource } from "../constants/interfaces" ; import { OurOptions , QueryDialect } from "../types" ; import { makePrefixedFullName } from "./makePrefixedFullName" ; export const makeIntrospectionOptions = ( options ) => { const prefix = ( s ) => makePrefixedFullName ( s , options ?. aliasPrefix ) ; const mutationOperationNames = { "nexus-prisma" : { [ CREATE ] : ( resource ) => prefix ( `createOne${ resource . name }` ) , [ UPDATE ] : ( resource ) => prefix ( `updateOne${ resource . name }` ) , [ DELETE ] : ( resource ) => prefix ( `deleteOne${ resource . name }` ) , } , typegraphql : { [ CREATE ] : ( resource ) => prefix ( `create${ resource . name }` ) , [ UPDATE ] : ( resource ) => prefix ( `update${ resource . name }` ) , [ DELETE ] : ( resource ) => prefix ( `delete${ resource . name }` ) , } , } ; return { operationNames : { [ GET_LIST ] : ( resource ) => prefix ( `${ pluralize ( camelCase ( resource . name ) ) }` ) , [ GET_ONE ] : ( resource ) => prefix ( `${ camelCase ( resource . name ) }` ) , [ GET_MANY ] : ( resource ) => prefix ( `${ pluralize ( camelCase ( resource . name ) ) }` ) , [ GET_MANY_REFERENCE ] : ( resource ) => prefix ( `${ pluralize ( camelCase ( resource . name ) ) }` ) , ... mutationOperationNames [ options . queryDialect ] , } , exclude : undefined , include : undefined , ... options . introspection , } ; } ;