GraphQL Starter

This starter shows how you can build a GraphQL server with Encore, implementing a basic url shortener as an example.

Developing locally

When you have installed Encore, you can create a new Encore application and clone this example with this command.

encore app create my-app-name --example=graphql

Running locally

Before running your application, make sure you have Docker installed and running. It's required to locally run Encore applications with databases.

encore run

While encore run is running, open http://localhost:9400/ to view Encore's local developer dashboard.

View the GraphQL Playground

Open http://localhost:4000/graphql/playground in your browser.

Using the API

Execute the below queries using the GraphQL Playground (or method of your choice).

Shorten a URL

mutation { shorten(url: "") { id url } }

Listing all shortened URLs

query { urls { id url } }

Getting a URL from a shortened ID

query { get(id: "some-id") { # Use an actual ID you have id url } }


Deploy your application to a staging environment in Encore's free development cloud:

git add -A . git commit -m 'Commit message' git push encore

Then head over to the Cloud Dashboard to monitor your deployment and find your production URL.

From there you can also connect your own AWS or GCP account to use for deployment.

Now off you go into the clouds!


encore test ./...