# graphql-participant

**Please familiarize yourself with [GraphQL at The Orchard](https://github.com/theorchard/docs/tree/master/graphql) before contributing!**

GraphQL service backed by Neo4j. See [neo4j-graphql-js](https://grandstack.io/docs/neo4j-graphql-js-quickstart.html) for more information.

## Running

```sh
awsume prod
```

1. Make sure you have `node` and `yarn` installed
2. To install private packages from https://packagecloud.io/

```
curl -s https://<PACKAGECLOUD_USER>:@packagecloud.io/install/repositories/orchardit/npm/script.node.sh | bash # configure packagecloud.io
```
3. Install dependencies: `yarn`
4. Copy the `.env.shadow` file to `.env` and fill in your information
5. Run the server: `yarn start`
6. Open your browser at [http://localhost:8080/graphql](http://localhost:8080/graphql)

## Running graphql-service with frontend service locally
1. This service uses jwt-service-handler private package. The package defaults to use QA auth0 creds for jwt token validation on local graphql setup. Make sure to use qa auth0 creds in your frontend service local setups so that they generate QA jwt and pass on in graphql calls.

## Debugging

In order to log the generated Cypher statements you can run `yarn start:debug` instead of `yarn start`.


## Examples

You can find some example queries in `tests/e2e/queries`.

## Auth

### `@withPermittedLabels` Directive
The `@withPermittedLabels` directive will expose an additional cypherParameter to custom cypher queries - `$cypherParams.permittedLabelNodeIds`, which contains zero or more permitted label nodes (Either `Vendor` or `SubAccount`.) This can also include the Global Vendor node. By default, it will contain all vendors that the user has access to, though by including the `vendorId` and `subaccountId` fields this can be narrowed down to a specific `Vendor` or `SubAccount` node.

## Troubleshooting

### Authentication Headers missing/JWT cache issues

Please ensure that you have used `awsume prod` if you intend to send JWT-authenticated requests to ows-* services. Otherwise, the JWT service cache initialization will silently fail and headers will not be passed along as expected. This behavior is expected to change once the service cache is no longer necessary.
