2.2.0 • Published 3 years ago

@aviosgroup/cbr-client v2.2.0

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
3 years ago

@avios/cbr-client

CBR Client is a module providing cbr graphql queries and a client to make the request

Installation

This module is published to npm as a private module. You'll need a token to install it or be logged in to npm as a user who is a member of the npm aviosgroup organisation

Usage

The module is installed in both the front and backend as a normal npm module, installed via lerna (lerna add @aviosgroup/cbr-client)

Modules can be imported in the normal es6 way...

const { cbr, merchants } = require('@aviosgroup/cbr-client');

If using standalone queries such as the getFlexibleMerchantsQuery from the merchants module, no additional setup is required. In the estore these are used with apollo graphql, where the fetch is handled by apollo

In the case of the estore backend however the fetch is done by the cbr client itself. In cases where you want to use cbr-client to do the fetch it requires config to be set;

import { CBR } from '@aviosgroup/cbr-client';
const { GRAPHQL_URL, GRAPHQL_ACCESS_KEY } = publicRuntimeConfig;
  CBR.setGraphQLConfig({
  URL: GRAPHQL_URL,
  ACCESS_KEY: GRAPHQL_ACCESS_KEY,
});

@TODO - Split the fetch behaviour from all the queries so we can optionally pass a flag to fetch the data in the cbr-client

Developing / Contributing

Running

When developing locally, use npm run start to have webpack compiling new versions on change

If linked in a Lerna environment you should not need to publish new versions to test the code in a project

Building

npm run build will build a production bundle

Publishing

When ready to release, its npm publish

Testing

There's two types of tests in cbr-client:

End-to-end

Mocking the response from the Hasura API using nock, you can see an example in test/merchants.test.js.

Query correctness assertion

We use graphql-tools and a copy of the Hasura schema (in test/support/schema.json) The example in test/merchants_query.test.js loads the schema and launches the query, if it is correct the library will return some default mock data.

It can be also used to return a specific mock. For more information check the official documentation here

If you need to refresh the Hasura schema you can use the Apollo client and then do a

apollo schema:download --endpoint https://staging.collection.and.avios.digital/v1/graphql --header 'X-Hasura-Admin-Secret: [HASURA_SECRET]'

this will create the schema.json file

2.2.0

3 years ago

2.1.0

3 years ago

1.4.6

4 years ago

1.4.9

4 years ago

1.4.8

4 years ago

1.4.7

4 years ago

1.4.5

4 years ago

1.4.4

4 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.14

4 years ago

1.1.13

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.1

4 years ago

1.1.2

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago