Skip to content

Commit

Permalink
tests: refactor for granularity
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Mar 17, 2021
1 parent ad1f708 commit ae31769
Show file tree
Hide file tree
Showing 9 changed files with 1,747 additions and 575 deletions.
7 changes: 4 additions & 3 deletions src/generator/models/declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,12 @@ export function fieldTypeToGraphQLType(field: DMMF.Field): LiteralUnion<Standard
case 'scalar': {
const typeName = field.type as PrismaScalarType

if (field.isId) {
return StandardgraphQLScalarTypes.ID
}

switch (typeName) {
case 'String': {
if (field.isId) {
return StandardgraphQLScalarTypes.ID
}
return StandardgraphQLScalarTypes.String
}
case 'Int': {
Expand Down
9 changes: 6 additions & 3 deletions tests/__helpers__.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ export function createSchema(content: string): string {
`
}

export async function generate(content: string): Promise<ModuleSpec[]> {
export async function generate(content: string): Promise<{ indexjs: string; indexdts: string }> {
const schema = createSchema(content)

const dmmf = await PrismaSDK.getDMMF({
datamodel: schema,
})

const runtime = generateRuntime(dmmf)
const [indexjs, indexdts] = generateRuntime(dmmf) as [ModuleSpec, ModuleSpec]

return runtime
return {
indexdts: indexdts.content,
indexjs: indexjs.content,
}
}

export function setupTestProject({
Expand Down
Loading

0 comments on commit ae31769

Please sign in to comment.