-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9e252c
commit 1c03aab
Showing
3 changed files
with
120 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { DMMFClass } from '../runtime/dmmf' | ||
import { makeDocument } from '../runtime/query' | ||
import { getDMMF } from '../generation/getDMMF' | ||
|
||
const datamodel = `\ | ||
datasource db { | ||
provider = "postgres" | ||
url = env("DB") | ||
} | ||
model User { | ||
id Int @id @default(autoincrement()) | ||
name String | ||
email String @unique | ||
json Json | ||
}` | ||
|
||
let dmmf | ||
beforeAll(async () => { | ||
const dmmfDocument = await getDMMF({ datamodel }) | ||
dmmf = new DMMFClass(dmmfDocument) | ||
}) | ||
|
||
describe('json', () => { | ||
test('should be able to create json', async () => { | ||
const document = makeDocument({ | ||
dmmf, | ||
select: { | ||
data: { | ||
email: 'a@a.de', | ||
json: { | ||
hello: 'world', | ||
}, | ||
name: 'Bob', | ||
}, | ||
}, | ||
rootTypeName: 'mutation', | ||
rootField: 'createOneUser', | ||
}) | ||
expect(String(document)).toMatchInlineSnapshot(` | ||
"mutation { | ||
createOneUser(data: { | ||
email: \\"a@a.de\\" | ||
json: \\"{\\\\\\"hello\\\\\\":\\\\\\"world\\\\\\"}\\" | ||
name: \\"Bob\\" | ||
}) { | ||
id | ||
name | ||
json | ||
} | ||
}" | ||
`) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ model User { | |
/// name comment | ||
name String? | ||
posts Post[] | ||
json Json? | ||
} | ||
model Post { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters