Skip to content

Commit a65fa1f

Browse files
committed
Update filter generation script to use g instead of graphql
1 parent d5c41b4 commit a65fa1f

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

prisma-utils/main.ts

+20-20
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ const SCALARS = ['String', 'Boolean', 'Int', 'Float', 'DateTime', 'Decimal', 'Bi
1515

1616
type Scalar = (typeof SCALARS)[number]
1717
const GRAPHQL_SCALARS = {
18-
String: 'graphql.String',
19-
Boolean: 'graphql.Boolean',
20-
Int: 'graphql.Int',
21-
Float: 'graphql.Float',
22-
Json: 'graphql.JSON',
23-
DateTime: 'graphql.DateTime',
24-
Decimal: 'graphql.Decimal',
25-
BigInt: 'graphql.BigInt',
18+
String: 'g.String',
19+
Boolean: 'g.Boolean',
20+
Int: 'g.Int',
21+
Float: 'g.Float',
22+
Json: 'g.JSON',
23+
DateTime: 'g.DateTime',
24+
Decimal: 'g.Decimal',
25+
BigInt: 'g.BigInt',
2626
} as const
2727

2828
function getSchemaForProvider (provider: Provider) {
@@ -64,24 +64,24 @@ function generateTSType (scalar: Scalar, filter: DMMF.InputType, nesting: boolea
6464
const filterName = filter.name.replace(/Bool/g, 'Boolean')
6565

6666
return [
67-
`type ${filterName}Type = graphql.InputObjectType<{`,
67+
`type ${filterName}Type = g.InputObjectType<{`,
6868
...filter.fields.map(field => {
6969
const suffix = field.isNullable ? ` // can be null` : ``
7070

7171
if (field.name === 'not') {
72-
if (nesting) return ` ${field.name}: graphql.Arg<Nested${filterName}Type>${suffix}`
73-
return ` ${field.name}: graphql.Arg<${filterName}Type>${suffix}`
72+
if (nesting) return ` ${field.name}: g.Arg<Nested${filterName}Type>${suffix}`
73+
return ` ${field.name}: g.Arg<${filterName}Type>${suffix}`
7474
}
7575

7676
if (['in', 'notIn'].includes(field.name)) {
77-
return ` ${field.name}: graphql.Arg<graphql.ListType<graphql.NonNullType<typeof ${gqlType}>>>${suffix}`
77+
return ` ${field.name}: g.Arg<g.ListType<g.NonNullType<typeof ${gqlType}>>>${suffix}`
7878
}
7979

8080
if (field.name === 'mode') {
81-
return ` ${field.name}: graphql.Arg<typeof QueryMode>${suffix}`
81+
return ` ${field.name}: g.Arg<typeof QueryMode>${suffix}`
8282
}
8383

84-
return ` ${field.name}: graphql.Arg<typeof ${gqlType}>${suffix}`
84+
return ` ${field.name}: g.Arg<typeof ${gqlType}>${suffix}`
8585
}),
8686
`}>`,
8787
].join('\n')
@@ -94,28 +94,28 @@ function generateGQLType (scalar: Scalar, filter: DMMF.InputType, nesting: boole
9494
const filterName = filter.name.replace(/Bool/g, 'Boolean')
9595

9696
return [
97-
`const ${filterName}: ${filterName}Type = graphql.inputObject({`,
97+
`const ${filterName}: ${filterName}Type = g.inputObject({`,
9898
` name: '${filterName}',`,
9999
` fields: () => ({`,
100100
...filter.fields.map(field => {
101101
const suffix = field.isNullable ? ` // can be null` : ``
102102

103103
if (field.name === 'mode') {
104-
return ` ${field.name}: graphql.arg({ type: QueryMode }),${suffix}`
104+
return ` ${field.name}: g.arg({ type: QueryMode }),${suffix}`
105105
}
106106

107107
if (field.name === 'not') {
108108
if (nesting) {
109-
return ` ${field.name}: graphql.arg({ type: Nested${filterName} }),${suffix}`
109+
return ` ${field.name}: g.arg({ type: Nested${filterName} }),${suffix}`
110110
}
111-
return ` ${field.name}: graphql.arg({ type: ${filterName} }),${suffix}`
111+
return ` ${field.name}: g.arg({ type: ${filterName} }),${suffix}`
112112
}
113113

114114
if (['in', 'notIn'].includes(field.name)) {
115-
return ` ${field.name}: graphql.arg({ type: graphql.list(graphql.nonNull(${gqlType})) }),${suffix}`
115+
return ` ${field.name}: g.arg({ type: g.list(g.nonNull(${gqlType})) }),${suffix}`
116116
}
117117

118-
return ` ${field.name}: graphql.arg({ type: ${gqlType} }),${suffix}`
118+
return ` ${field.name}: g.arg({ type: ${gqlType} }),${suffix}`
119119
}),
120120
` }),`,
121121
`})`,

0 commit comments

Comments
 (0)