* removing batch info from the url * small CR changes Co-authored-by: Sreeraj Rajendran Nair <sreeraj.rajendran@photowall.com>
graphql-api-js
Apollo graphql api server for Photowall
Run it locally
Create an .env file (see .env.example for what to set).
Development
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.
If you dont have access to photowall shared lastpass please contact any collegaue.
Run prod-like container locally
Run
$ docker compose -f docker-compose-prodlike.yml build
$ docker compose -f docker-compose-prodlike.yml up
Get your AD-token from this path in the browser <url to photowall>/admin/auth/token
Take the value of the token param and add header in insomnia:Authorization: Bearer .
The token is valid for 2-3 hours.
Run tests
Scripts will create the insert sql files for a randomized fake data postgres database. This database is based of the actual db in photowall project.
npm test
Writing tests
The tests are held in testcontainers testcontainers-node. One container holding a test postgres database and one container started from the Dockerfile containing the Apollo GraphQL server. These containers have connections with each other.
Each test is build around inserting fake data in the empty db, fetching that data through the GraphQL and with raw Sql queries and then comparing the results.
To write new inserts into the DB generate sql files with js in the src/test/db_generator tool. Then load the new sql file in the containerSetup.ts file.
When you have the data you need in the db, write tests in all.test.ts file following the pattern already set.