This starter shows how you can build a GraphQL server with Encore, implementing a basic url shortener as an example.
Install Encore:
brew install encoredev/tap/encore
curl -L https://encore.dev/install.sh | bash
iwr https://encore.dev/install.ps1 | iex
Docker:
Create a local app from this template:
encore app create my-app-name --example=graphql
Before running your application, make sure you have Docker installed and running. Then run this command from your application's root folder:
encore run
While encore run
is running, open http://localhost:9400/ to view Encore's local developer dashboard.
Open http://localhost:4000/graphql/playground in your browser.
Execute the below queries using the GraphQL Playground (or method of your choice).
mutation { shorten(url: "https://encore.dev") { id url } }
query { urls { id url } }
query { get(id: "some-id") { # Use an actual ID you have id url } }
See the self-hosting instructions for how to use encore build docker
to create a Docker image and configure it.
Deploy your application to a free staging environment in Encore's development cloud using git push encore
:
git add -A .
git commit -m 'Commit message'
git push encore
You can also open your app in the Cloud Dashboard to integrate with GitHub, or connect your AWS/GCP account, enabling Encore to automatically handle cloud deployments for you.
Follow these steps to link your app to GitHub:
encore test ./...