2024-03-13 10:40:32 +01:00
2022-02-23 13:05:44 +01:00
2021-10-11 16:53:18 +02:00
2024-03-07 13:07:00 +01:00
2021-06-17 11:04:22 +02:00
2021-07-26 10:35:52 +02:00
WIP
2021-04-06 09:56:18 +02:00
2023-08-31 19:42:39 +02:00
2021-07-26 10:35:52 +02:00

graphql-api-js

Apollo graphql api server for Photowall

This servers runs in two instances on AWS. graphql.photowall.com is used for photowall admin. data.photowall.com is used by the website (client). When clients want to use the public data.photowall.com they use the /login REST endpoint to retreive a BearerToken with restricted cognito scopes. They can then access certain product and designer information with the token.

Third party systems like Unbox (Synergy) will use the graphql.photowall.com to read their data like they are doing now. This is to make sure the website wont be affected by larger downloads of data like unbox does. Unbox has their own cognito app client with limited scopes.

Running queries on staging or production servers

To tests staging or production servers its possible to run the login rest endpoint to get a Bearer access token. Check SSM for the stacks ${EnvironmentName}/GRAPHQL_WEB_CLIENT_USERNAME and ${EnvironmentName}/GRAPHQL_WEB_CLIENT_PASSWORD and use those as Basic auth for the /login route. To get a token from admin go to the route /auth/token. You can then use that token as a Bearer token in apps like Insomnia.

Running it locally

.env file

Create an .env file in repo root (see .env.example for what to set). Depending on which resolvers you are going to use different environment variables are needed. Begin by setting DATABASE_URL at least, the rest can be added as needed.

Notes: COGNITO_LOGIN_CLIENT_ID and COGNITO_LOGIN_CLIENT_SECRET found in cognito photowall-test-staff pool. In photowall-web-test-client app but are only needed for testing or using the /login route to get proper Bearer authentication.

Development

This project runs in docker, so when developing start the docker environment and it will restart automatically when .graphql (schema) or .ts files are changed.

Run

$ npm install
$ docker compose build
$ docker compose up

For testing use a tool like Insomnia or similar. Server is running on http://localhost:4000/ and to connect you need to use basic auth with username and password from "GraphQl Basic Auth" in lastpass. If you wish the Bearer Token used in prodlike environment also works. See note under ".env file: above.

If you don't have access to photowall shared lastpass please contact any colleague.

If you use Insomnia ask a colleague for the queries that can be exported/imported from Insomnia.

Publish feature branch to staging

Run make publish-to-staging. Please note that further commits on the same branch will not be updated automatically and the same command must be run again if changes are made.

Run prod-like container locally

Run

$ docker compose -f docker-compose-prodlike.yml build
$ docker compose -f docker-compose-prodlike.yml up

To access it you must use the login endpoint to get a Bearer token

Run tests

Tests

npm test

Force update staging

update 5

S
Description
No description provided
Readme
1.4 MiB
Languages
TypeScript 96.2%
Makefile 2.9%
JavaScript 0.7%
Dockerfile 0.2%