Skip to content

Commit

Permalink
test(graphql-default-value-transformer): @default cannot be used on c…
Browse files Browse the repository at this point in the history
…omposite key members
  • Loading branch information
p5quared committed Sep 16, 2024
1 parent cbc28fd commit 203e382
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,22 @@ describe('DefaultValueModelTransformer:', () => {
).toThrow('The @default directive may not be applied to primaryKey fields.');
});

it('throws if @default is used on a composite key member', () => {
const schema = `
type Project @model {
projectId: ID! @primaryKey(sortKeyFields: ["name"])
name: String! @default(value: "Mustapha Mond")
}
`;

expect(() =>
testTransform({
schema,
transformers: [new ModelTransformer(), new DefaultValueTransformer(), new PrimaryKeyTransformer()],
}),
).toThrow('The @default directive may not be applied to composite key member fields.');
});

it('should validate enum values', async () => {
const inputSchema = `
type Post @model {
Expand Down

0 comments on commit 203e382

Please sign in to comment.