Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/strise/strise-api-demo
https://github.com/strise/strise-api-demo
Last synced: 29 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/strise/strise-api-demo
- Owner: strise
- Created: 2021-02-11T18:25:33.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-26T15:34:46.000Z (almost 2 years ago)
- Last Synced: 2023-03-09T00:03:00.889Z (almost 2 years ago)
- Language: TypeScript
- Size: 475 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Strise API Demo
This repository contains an example React app using the Strise Process API for streaming updates about companies. Most of the code can be used in a server application as well.
A deployed version of the app can be found [here](https://api-demo.strise.ai).
## GraphQL WebSocket Protocol
The Strise Process API adheres to the [graphql-transport-ws](https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md) protocol and clients must follow this specification. The [`graphql-ws`](https://github.com/enisdenjo/graphql-ws) NPM package supports this out of the box.
## Authentication
The client authenticates against the API using a [JSON Web Token](https://jwt.io/). The token must be included in the payload of the initial message.
```json
{
"type": "connection_init",
"payload": {
"Authorization": "Bearer token"
}
}
```When using Apollo this the token is provided as in the example [`src/utils/client.tsx`](src/utils/client.tsx).
## API documentation
The API documentation can be viewed in the hosted [GraphQL Playground](https://graphql.strise.ai/process/graphiql), or with any other GraphQL client / documentation explorer.
## Codegen
One advantage of using a strongly typed API is that it is possible to generate custom types based on the current integration.
In this example [`graphql-codegen`](https://graphql-code-generator.com/) is used to generate TypeScript types based on the GraphQL operations specified in the files in `src/graphql`. The configuration can be found in `codegen.yml`.
`graphql-codegen` also has plugins for generating types in other languases such as Java or C#. Alternative codegen tools might also support other languages.
## Development
1. Install dependencies `npm install`
2. Start the development server `npm run dev:stage`