Skip to content

Commit

Permalink
feat(graphql-default-value-transformer): implemented default value di…
Browse files Browse the repository at this point in the history
…rective (#8291)
  • Loading branch information
lazpavel committed Oct 8, 2021
1 parent 2468f86 commit 130aba1
Show file tree
Hide file tree
Showing 15 changed files with 1,087 additions and 0 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module.exports = {
'<rootDir>/packages/amplify-graphql-function-transformer',
'<rootDir>/packages/amplify-graphql-http-transformer',
'<rootDir>/packages/amplify-graphql-index-transformer',
'<rootDir>/packages/amplify-graphql-default-value-transformer',
'<rootDir>/packages/amplify-graphql-model-transformer',
'<rootDir>/packages/amplify-graphql-predictions-transformer',
'<rootDir>/packages/amplify-graphql-relational-transformer',
Expand Down
Empty file.
13 changes: 13 additions & 0 deletions packages/amplify-graphql-default-value-transformer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# GraphQL @default Transformer

# Reference Documentation

### @default

The `@default` directive allows you to define the default value for your field.

#### Definition

```graphql
directive @default(value: String) on FIELD_DEFINITION
```
57 changes: 57 additions & 0 deletions packages/amplify-graphql-default-value-transformer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "@aws-amplify/graphql-default-value-transformer",
"version": "0.1.0",
"description": "Amplify GraphQL default value transformer",
"repository": {
"type": "git",
"url": "https://github.com/aws-amplify/amplify-cli.git",
"directory": "packages/amplify-graphql-default-value-transformer"
},
"author": "Amazon Web Services",
"license": "Apache-2.0",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"keywords": [
"graphql",
"cloudformation",
"aws",
"amplify"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"clean": "rimraf ./lib",
"test": "jest",
"test-watch": "jest --watch"
},
"dependencies": {
"@aws-amplify/graphql-transformer-interfaces": "1.9.1",
"@aws-amplify/graphql-transformer-core": "0.9.1",
"graphql-mapping-template": "4.18.3",
"graphql-transformer-common": "4.19.10",
"graphql": "^14.5.8",
"libphonenumber-js": "^1.7.31"
},
"devDependencies": {
"@aws-cdk/assert": "~1.124.0"
},
"jest": {
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testURL": "http://localhost",
"testRegex": "(src/__tests__/.*\\.(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"collectCoverage": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DefaultValueModelTransformer: should successfully transform simple valid schema 1`] = `
"
type Post {
id: ID!
stringValue: String
intVal: Int
floatValue: Float
booleanValue: Boolean
awsJsonValue: AWSJSON
awsDateValue: AWSDate
awsTimestampValue: AWSTimestamp
awsEmailValue: AWSEmail
awsURLValue: AWSURL
awsPhoneValue: AWSPhone
awsIPAddressValue1: AWSIPAddress
awsIPAddressValue2: AWSIPAddress
enumValue: Tag
awsTimeValue: AWSTime
awsDateTime: AWSDateTime
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
}
enum Tag {
NEWS
RANDOM
}
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
}
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 ModelPostConnection {
items: [Post]
nextToken: String
}
input ModelTagInput {
eq: Tag
ne: Tag
}
input ModelPostFilterInput {
id: ModelIDInput
stringValue: ModelStringInput
intVal: ModelIntInput
floatValue: ModelFloatInput
booleanValue: ModelBooleanInput
awsJsonValue: ModelStringInput
awsDateValue: ModelStringInput
awsTimestampValue: ModelIntInput
awsEmailValue: ModelStringInput
awsURLValue: ModelStringInput
awsPhoneValue: ModelStringInput
awsIPAddressValue1: ModelStringInput
awsIPAddressValue2: ModelStringInput
enumValue: ModelTagInput
awsTimeValue: ModelStringInput
awsDateTime: ModelStringInput
and: [ModelPostFilterInput]
or: [ModelPostFilterInput]
not: ModelPostFilterInput
}
type Query {
getPost(id: ID!): Post
listPosts(filter: ModelPostFilterInput, limit: Int, nextToken: String): ModelPostConnection
}
input ModelPostConditionInput {
stringValue: ModelStringInput
intVal: ModelIntInput
floatValue: ModelFloatInput
booleanValue: ModelBooleanInput
awsJsonValue: ModelStringInput
awsDateValue: ModelStringInput
awsTimestampValue: ModelIntInput
awsEmailValue: ModelStringInput
awsURLValue: ModelStringInput
awsPhoneValue: ModelStringInput
awsIPAddressValue1: ModelStringInput
awsIPAddressValue2: ModelStringInput
enumValue: ModelTagInput
awsTimeValue: ModelStringInput
awsDateTime: ModelStringInput
and: [ModelPostConditionInput]
or: [ModelPostConditionInput]
not: ModelPostConditionInput
}
input CreatePostInput {
id: ID
stringValue: String
intVal: Int
floatValue: Float
booleanValue: Boolean
awsJsonValue: AWSJSON
awsDateValue: AWSDate
awsTimestampValue: AWSTimestamp
awsEmailValue: AWSEmail
awsURLValue: AWSURL
awsPhoneValue: AWSPhone
awsIPAddressValue1: AWSIPAddress
awsIPAddressValue2: AWSIPAddress
enumValue: Tag
awsTimeValue: AWSTime
awsDateTime: AWSDateTime
}
input UpdatePostInput {
id: ID!
stringValue: String
intVal: Int
floatValue: Float
booleanValue: Boolean
awsJsonValue: AWSJSON
awsDateValue: AWSDate
awsTimestampValue: AWSTimestamp
awsEmailValue: AWSEmail
awsURLValue: AWSURL
awsPhoneValue: AWSPhone
awsIPAddressValue1: AWSIPAddress
awsIPAddressValue2: AWSIPAddress
enumValue: Tag
awsTimeValue: AWSTime
awsDateTime: AWSDateTime
}
input DeletePostInput {
id: ID!
}
type Mutation {
createPost(input: CreatePostInput!, condition: ModelPostConditionInput): Post
updatePost(input: UpdatePostInput!, condition: ModelPostConditionInput): Post
deletePost(input: DeletePostInput!, condition: ModelPostConditionInput): Post
}
type Subscription {
onCreatePost: Post @aws_subscribe(mutations: [\\"createPost\\"])
onUpdatePost: Post @aws_subscribe(mutations: [\\"updatePost\\"])
onDeletePost: Post @aws_subscribe(mutations: [\\"deletePost\\"])
}
"
`;

0 comments on commit 130aba1

Please sign in to comment.