Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integration tests for graphql resource package #5271

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tests/integration/package/test_package_command_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def test_package_nested_template(self, template_file, uploading_count):
"aws-serverless-statemachine.yaml",
"aws-stepfunctions-statemachine.yaml",
"aws-include-transform.yaml",
"aws-serverless-graphqlapi.yaml",
]
)
def test_package_barebones(self, template_file):
Expand Down Expand Up @@ -140,6 +141,7 @@ def test_package_without_required_args(self):
"aws-serverlessrepo-application.yaml",
"aws-serverless-statemachine.yaml",
"aws-stepfunctions-statemachine.yaml",
"aws-serverless-graphqlapi.yaml",
]
)
def test_package_with_prefix(self, template_file):
Expand Down Expand Up @@ -183,6 +185,7 @@ def test_package_with_prefix(self, template_file):
"aws-serverlessrepo-application.yaml",
"aws-serverless-statemachine.yaml",
"aws-stepfunctions-statemachine.yaml",
"aws-serverless-graphqlapi.yaml",
]
)
def test_package_with_output_template_file(self, template_file):
Expand Down Expand Up @@ -237,6 +240,7 @@ def test_package_with_output_template_file(self, template_file):
"aws-serverlessrepo-application.yaml",
"aws-serverless-statemachine.yaml",
"aws-stepfunctions-statemachine.yaml",
"aws-serverless-graphqlapi.yaml",
]
)
def test_package_with_json(self, template_file):
Expand Down Expand Up @@ -292,6 +296,7 @@ def test_package_with_json(self, template_file):
"aws-serverlessrepo-application.yaml",
"aws-serverless-statemachine.yaml",
"aws-stepfunctions-statemachine.yaml",
"aws-serverless-graphqlapi.yaml",
]
)
def test_package_with_force_upload(self, template_file):
Expand Down Expand Up @@ -349,6 +354,7 @@ def test_package_with_force_upload(self, template_file):
"aws-serverlessrepo-application.yaml",
"aws-serverless-statemachine.yaml",
"aws-stepfunctions-statemachine.yaml",
"aws-serverless-graphqlapi.yaml",
]
)
def test_package_with_kms_key(self, template_file):
Expand Down Expand Up @@ -405,6 +411,7 @@ def test_package_with_kms_key(self, template_file):
"aws-serverlessrepo-application.yaml",
"aws-serverless-statemachine.yaml",
"aws-stepfunctions-statemachine.yaml",
"aws-serverless-graphqlapi.yaml",
]
)
def test_package_with_metadata(self, template_file):
Expand Down Expand Up @@ -460,6 +467,7 @@ def test_package_with_metadata(self, template_file):
"aws-serverlessrepo-application.yaml",
"aws-serverless-statemachine.yaml",
"aws-stepfunctions-statemachine.yaml",
"aws-serverless-graphqlapi.yaml",
]
)
def test_package_with_resolve_s3(self, template_file):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Transform: AWS::Serverless-2016-10-31

Resources:
DynamoDBPostsTable:
Type: AWS::Serverless::SimpleTable

SuperCoolAPI:
Type: AWS::Serverless::GraphQLApi
Properties:
SchemaUri: ./sam_graphql_api/schema.graphql
Auth:
Type: AWS_IAM
DataSources:
DynamoDb:
PostsDataSource:
TableName: !Ref DynamoDBPostsTable
TableArn: !GetAtt DynamoDBPostsTable.Arn
Functions:
createPostItem:
Runtime:
Name: APPSYNC_JS
Version: "1.0.0"
DataSource: PostsDataSource
CodeUri: ./sam_graphql_api/createPostItem.js
getPostFromTable:
Runtime:
Name: APPSYNC_JS
Version: "1.0.0"
DataSource: PostsDataSource
CodeUri: ./sam_graphql_api/getPostFromTable.js
Resolvers:
Mutation:
addPost:
Runtime:
Name: APPSYNC_JS
Version: "1.0.0"
Pipeline:
- createPostItem
Query:
getPost:
CodeUri: ./sam_graphql_api/getPost.js
Runtime:
Name: APPSYNC_JS
Version: "1.0.0"
Pipeline:
- getPostFromTable
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { util } from "@aws-appsync/utils";

export function request(ctx) {
return dynamoDBGetItemRequest({ id: ctx.args.id });
}

export function response(ctx) {
return ctx.result;
}

/**
* A helper function to get a DynamoDB item
*/
function dynamoDBGetItemRequest(key) {
return {
operation: "GetItem",
key: util.dynamodb.toMapValues(key),
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function request(ctx) {
return {};
}

export function response(ctx) {
return ctx.prev.result;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { util } from "@aws-appsync/utils";

export function request(ctx) {
return dynamoDBGetItemRequest({ id: ctx.args.id });
}

export function response(ctx) {
return ctx.result;
}

/**
* A helper function to get a DynamoDB item
*/
function dynamoDBGetItemRequest(key) {
return {
operation: "GetItem",
key: util.dynamodb.toMapValues(key),
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
schema {
query: Query
mutation: Mutation
}

type Query {
getPost(id: String!): Post
}

type Mutation {
addPost(author: String!, title: String!, content: String!): Post!
}

type Post {
id: String!
author: String
title: String
content: String
ups: Int!
downs: Int!
version: Int!
}