This is a sample application on how to use the Azure Static Web App Database Connections feature to expose Cosmos DB with GraphQL.
The application is written in React (with TypeScript), uses GraphQL Code Generator to generate TypeScript types from the GraphQL schema, and Apollo Client to query the GraphQL API.
You can learn more about it in the companion blog post.
This repo contains a VSCode devcontainer configuration, so you can open the repo in VSCode and have it provision a local Cosmos DB emulator instance for you. You can use the Azure Database VS Code extension to connect to the emulator and create a database and collection. There's also a sample dataset that can be uploaded at data/trivia.json
.
Once the database is provisioned you can run npm install
followed by npm start
then navigate to http://localhost:4280.