-
Notifications
You must be signed in to change notification settings - Fork 816
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(graphql-default-value-transformer): implemented default value di…
…rective (#8291)
- Loading branch information
Showing
15 changed files
with
1,087 additions
and
0 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
Empty file.
13 changes: 13 additions & 0 deletions
13
packages/amplify-graphql-default-value-transformer/README.md
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,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
57
packages/amplify-graphql-default-value-transformer/package.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 |
---|---|---|
@@ -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 | ||
} | ||
} |
235 changes: 235 additions & 0 deletions
235
...ormer/src/__tests__/__snapshots__/amplify-grapphql-default-value-transformer.test.ts.snap
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,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\\"]) | ||
} | ||
" | ||
`; |
Oops, something went wrong.