This starter shows how you can build a GraphQL server with Encore, implementing a basic url shortener as an example.
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
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.
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
}
}
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 ./...