Skip to content
Draft
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
35 changes: 22 additions & 13 deletions templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ You should specify those arguments [as per the documentation](https://kubernetes

# APIs Specification

## Environment Settings
## Environment Settings
Before you get presigned url from S3, make sure the following environment variables have been set.
Variable | Description
--- | ---
Variable | Description
--- | ---
AWS_ACCESS_KEY_ID | The IMA user's access key id with full control permission to S3
AWS_Secret_Access_Key | The IMA user's secret access key
AWS_REGION | The AWS region, such as "us-east-1", "us-west-2"
Expand All @@ -100,10 +100,10 @@ AWS_S3_DEFAULT_BUCKET | optional, default bucket is applied if the bucket name i
```
GET /file/presigned?key=filepath[&bucket=bucketname]
```
Note: The path variable :key doesn't allow the value is a path which includes '/' so that we change it from path variable to a query string
Note: The path variable :key doesn't allow the value is a path which includes '/' so that we change it from path variable to a query string
### Parameters
Parameter | Description
--- | ---
Parameter | Description
--- | ---
key | The path+filename on the Bucket
bucket | The bucket name on S3. The default value will be applied if it isn't given.

Expand All @@ -116,8 +116,8 @@ curl --location --request GET 'http://localhost:8090/file/presigned?key=images/w
curl --location --request GET 'http://localhost:8090/file/presigned/key=images/windows.png&bucket=bigfile-bucket'
```
### Response Body
Properties | Description
--- | ---
Properties | Description
--- | ---
url | The presigned url of uploading a file
method | The method of request to upload the file

Expand Down Expand Up @@ -146,8 +146,8 @@ curl --location --request PUT 'https://bigfile-bucket.s3.us-west-2.amazonaws.com
GET /file?key=filepath[&bucket=bucketname]
```
### Parameters
Parameter | Description
--- | ---
Parameter | Description
--- | ---
key | The path+filename on the Bucket
bucket | Optional, The bucket name on S3. The default value will be applied if it isn't given.

Expand All @@ -160,8 +160,8 @@ curl --location --request GET 'http://localhost:8090/file?key=images/windows.png
curl --location --request GET 'http://localhost:8090/file?key=images/windows.png&bucket=bigfile-bucket'bucket=bigfile-bucket'
```
### Response Body
Properties | Description
--- | ---
Properties | Description
--- | ---
url | The presigned url of uploading a file
method | The method of request to upload the file

Expand All @@ -177,9 +177,18 @@ method | The method of request to upload the file
Copy this presigned url and paste it into your browser, then done.
#### download through curl
```
curl --location --request GET '[presigned url for download]'
curl --location --request GET '[presigned url for download]'
```

<%if eq (index .Params `apiType`) "graphql" %>
# GraphQL Schema Updates
After making changes to the `/graph/schema.graphqls` GraphQL schema, run the following command to generate new resolver implementation stubs:

```
$ go generate ./...
```
<% end %>

# Database Migration
Database migrations are handled with [Flyway](https://flywaydb.org/). Migrations run in a docker container started in the Kubernetes cluster by CircleCI or the local dev environment startup process.

Expand Down
4 changes: 3 additions & 1 deletion templates/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ module <% .Files.Repository %>
go 1.14

require (
github.com/99designs/gqlgen v0.13.0
github.com/aws/aws-sdk-go v1.37.6
github.com/jinzhu/gorm v1.9.16
github.com/jinzhu/gorm v1.9.16
github.com/joho/godotenv v1.3.0
github.com/vektah/gqlparser/v2 v2.1.0
)
56 changes: 56 additions & 0 deletions templates/gqlgen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Where are all the schema files located? globs are supported eg src/**/*.graphqls
schema:
- graph/*.graphqls

# Where should the generated server code go?
exec:
filename: graph/generated/generated.go
package: generated

# Uncomment to enable federation
# federation:
# filename: graph/generated/federation.go
# package: generated

# Where should any generated models go?
model:
filename: graph/model/models_gen.go
package: model

# Where should the resolver implementations go?
resolver:
layout: follow-schema
dir: graph
package: graph

# Optional: turn on use `gqlgen:"fieldName"` tags in your models
# struct_tag: json

# Optional: turn on to use []Thing instead of []*Thing
# omit_slice_element_pointers: false

# Optional: set to speed up generation time by not performing a final validation pass.
# skip_validation: true

# gqlgen will search for any type names in the schema in these go packages
# if they match it will use them, otherwise it will generate them.
autobind:
- "<% .Files.Repository %>/graph/model"

# This section declares type mapping between the GraphQL and go type systems
#
# The first line in each type will be used as defaults for resolver arguments and
# modelgen, the others will be allowed when binding to fields. Configure them to
# your liking
models:
ID:
model:
- github.com/99designs/gqlgen/graphql.ID
- github.com/99designs/gqlgen/graphql.Int
- github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.Int32
Int:
model:
- github.com/99designs/gqlgen/graphql.Int
- github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.Int32
Loading