Skip to content

Commit

Permalink
test(graphql-default-value-transformer): pk can be auto increment
Browse files Browse the repository at this point in the history
  • Loading branch information
p5quared committed Oct 1, 2024
1 parent 745cac9 commit de142bd
Show file tree
Hide file tree
Showing 2 changed files with 242 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,227 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DefaultValueModelTransformer: should allow auto-increment primary key 1`] = `
"type CoffeeQueue {
orderNumber: Int!
customer: String!
order: String
}
input ModelStringInput {
ne: String
eq: String
le: String
lt: String
ge: String
gt: String
contains: String
notContains: String
between: [String]
beginsWith: String
attributeExists: Boolean
attributeType: ModelAttributeTypes
size: ModelSizeInput
}
input ModelIntInput {
ne: Int
eq: Int
le: Int
lt: Int
ge: Int
gt: Int
between: [Int]
attributeExists: Boolean
attributeType: ModelAttributeTypes
}
input ModelFloatInput {
ne: Float
eq: Float
le: Float
lt: Float
ge: Float
gt: Float
between: [Float]
attributeExists: Boolean
attributeType: ModelAttributeTypes
}
input ModelBooleanInput {
ne: Boolean
eq: Boolean
attributeExists: Boolean
attributeType: ModelAttributeTypes
}
input ModelIDInput {
ne: ID
eq: ID
le: ID
lt: ID
ge: ID
gt: ID
contains: ID
notContains: ID
between: [ID]
beginsWith: ID
attributeExists: Boolean
attributeType: ModelAttributeTypes
size: ModelSizeInput
}
input ModelSubscriptionStringInput {
ne: String
eq: String
le: String
lt: String
ge: String
gt: String
contains: String
notContains: String
between: [String]
beginsWith: String
in: [String]
notIn: [String]
}
input ModelSubscriptionIntInput {
ne: Int
eq: Int
le: Int
lt: Int
ge: Int
gt: Int
between: [Int]
in: [Int]
notIn: [Int]
}
input ModelSubscriptionFloatInput {
ne: Float
eq: Float
le: Float
lt: Float
ge: Float
gt: Float
between: [Float]
in: [Float]
notIn: [Float]
}
input ModelSubscriptionBooleanInput {
ne: Boolean
eq: Boolean
}
input ModelSubscriptionIDInput {
ne: ID
eq: ID
le: ID
lt: ID
ge: ID
gt: ID
contains: ID
notContains: ID
between: [ID]
beginsWith: ID
in: [ID]
notIn: [ID]
}
enum ModelAttributeTypes {
binary
binarySet
bool
list
map
number
numberSet
string
stringSet
_null
}
input ModelSizeInput {
ne: Int
eq: Int
le: Int
lt: Int
ge: Int
gt: Int
between: [Int]
}
enum ModelSortDirection {
ASC
DESC
}
type ModelCoffeeQueueConnection {
items: [CoffeeQueue]!
nextToken: String
}
input ModelCoffeeQueueFilterInput {
orderNumber: ModelIntInput
customer: ModelStringInput
order: ModelStringInput
and: [ModelCoffeeQueueFilterInput]
or: [ModelCoffeeQueueFilterInput]
not: ModelCoffeeQueueFilterInput
}
type Query {
getCoffeeQueue(orderNumber: Int!): CoffeeQueue
listCoffeeQueues(orderNumber: Int, filter: ModelCoffeeQueueFilterInput, limit: Int, nextToken: String, sortDirection: ModelSortDirection): ModelCoffeeQueueConnection
}
input ModelCoffeeQueueConditionInput {
customer: ModelStringInput
order: ModelStringInput
and: [ModelCoffeeQueueConditionInput]
or: [ModelCoffeeQueueConditionInput]
not: ModelCoffeeQueueConditionInput
}
input CreateCoffeeQueueInput {
orderNumber: Int
customer: String!
order: String
}
input UpdateCoffeeQueueInput {
orderNumber: Int!
customer: String
order: String
}
input DeleteCoffeeQueueInput {
orderNumber: Int!
}
type Mutation {
createCoffeeQueue(input: CreateCoffeeQueueInput!, condition: ModelCoffeeQueueConditionInput): CoffeeQueue
updateCoffeeQueue(input: UpdateCoffeeQueueInput!, condition: ModelCoffeeQueueConditionInput): CoffeeQueue
deleteCoffeeQueue(input: DeleteCoffeeQueueInput!, condition: ModelCoffeeQueueConditionInput): CoffeeQueue
}
input ModelSubscriptionCoffeeQueueFilterInput {
orderNumber: ModelSubscriptionIntInput
customer: ModelSubscriptionStringInput
order: ModelSubscriptionStringInput
and: [ModelSubscriptionCoffeeQueueFilterInput]
or: [ModelSubscriptionCoffeeQueueFilterInput]
}
type Subscription {
onCreateCoffeeQueue(filter: ModelSubscriptionCoffeeQueueFilterInput): CoffeeQueue @aws_subscribe(mutations: [\\"createCoffeeQueue\\"])
onUpdateCoffeeQueue(filter: ModelSubscriptionCoffeeQueueFilterInput): CoffeeQueue @aws_subscribe(mutations: [\\"updateCoffeeQueue\\"])
onDeleteCoffeeQueue(filter: ModelSubscriptionCoffeeQueueFilterInput): CoffeeQueue @aws_subscribe(mutations: [\\"deleteCoffeeQueue\\"])
}
"
`;

exports[`DefaultValueModelTransformer: should be supported on a required field. 1`] = `
"type Test {
id: ID!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,24 @@ describe('DefaultValueModelTransformer:', () => {
const parsedSchema = parse(out.schema);
validateModelSchema(parsedSchema);
});

it('should allow auto-increment primary key', async () => {
const schema = `
type CoffeeQueue @model {
orderNumber: Int! @primaryKey @default
order: String!
customer: String
}
`;
const strategy = mockSqlDataSourceStrategy({ dbType: POSTGRES_DB_TYPE });
const out = testTransform({
schema,
transformers: [new ModelTransformer(), new DefaultValueTransformer(), new PrimaryKeyTransformer()],
dataSourceStrategies: constructDataSourceStrategies(schema, strategy),
});
expect(out).toBeDefined();
expect(out.schema).toMatchSnapshot();
const parsedSchema = parse(out.schema);
validateModelSchema(parsedSchema);
});
});

0 comments on commit de142bd

Please sign in to comment.