This repository contains example code for Commitspark, the workflow-first Content Management System based on Git and GraphQL.
If you want to expose the GraphQL endpoint and schema generated by Commitspark over HTTP, the Commitspark GraphQL library can be wrapped in a web server such as Express. This repository here holds an example implementation of such a server, configured to manage content in a GitHub-based content repository.
In case you simply want to work with content in your own JavaScript- or TypeScript-based application, you may be better off by running queries and mutations directly against the Commitspark GraphQL library, without first going through HTTP. If this is the case, this example here is not relevant for you.
-
Run
npm install
-
Obtain a GitHub "personal access token (classic)" according to the GitHub documentation from here. Make sure to select the top-level scope
repo
. -
Get the repository owner and repository name for your content repository.
For example, a repository at
https://github.com/my-org/my-content-repository
has ownermy-org
and repository namemy-content-repository
. -
Copy
.env.dist
to.env
and fill in your repository owner, name, and GitHub access token. -
Compile your code with
npm run build
(and do so again after every code change). -
Run your server with
npm run start
.
The GraphQL endpoint is then available under http://localhost:3000/main/graphql
and the generated GraphQL schema as plaintext under
http://localhost:3000/main/schema (where main
is the name of a valid branch
in your content repository).