This is a simple GraphQL endpoint demoing using Up
by Apex to deploy to AWS Lambda and using AWS Fargate to deploy Engine and link them together.
- Engine does not currently support non GraphQL requests with Lambda. This means using GraphiQL or an auth check for private caching are not possible as they aren't GraphQL requests Issue
- Install Up
- Setup an IAM policy for up like this
npm install
in this repo- run
up
in this directory to deploy and create a Lambda - Setup a new service in Engine
- Setup an IAM policy with LambdaInvoke (this is overly wide policy here, could be more narrow) for an engine user and use in next step.
- Create a config JSON like so with values from Engine, Lambda, and IAM credentials:
{
"apiKey": "<ENGINE_API_KEY>",
"origins": [
{
"lambda": {
"functionArn":"<LAMBDA_ARN>",
"awsAccessKeyId":"<AWS_IAM_ID>",
"awsSecretAccessKey":"<AWS_IAM_KEY>"
}
}
],
"frontends": [
{
"host": "0.0.0.0",
"port": 80,
"endpoints": ["/", "/development", "/staging", "/production"]
}
]
}
- Stringify this so it can be used with Fargate (hint in chrome you can run
copy(JSON.stringify(<the above json>))
to copy it to your clipboard). It is worth saving this somewhere for future ease of use. - To to this link to start using Fargate for a service
- Choose
custom
and enter the following information:
Container Name: Engine
Image: gcr.io/mdg-public/engine:2018.02-37-g678cbb68b
Port Mappings: 80 / TCP
Advanced:
Env Variables:
ENGINE_CONFIG: <the stringified JSON from above>
- Edit the task definition to set name to be engine-proxy and click next
- Choose ALB (Application Load Balancer) and click next
- Set cluster name to Engine and click next
- Click create and wait until everything is ready
- After the cluster is ready, click to the Engine-service and clik into the target group link
- Edit health check to be
/.well-known/apollo/engine-health
- Click back to Description and click the Load Balancer link
- Copy the DNS name into the electron version of GraphiQL with
http://
proceding it. - Paste this query and hit go:
query Test {
hero(episode:NEWHOPE){
name
}
}
- Profit (or replicate the above bugs)
- GraphiQL is turned off on this demo because it doesn't work (see included youtrack ticket above). Adding it back in is super easy, just follow the docs on apollo server for apollo-server-express
- Introspection query is just broken, if you type
up url --copy
you can replace the url in graphiql with what is in your clipboard and see Introspection works and tracing is included.