kc-npm-module-d
TypeScript icon, indicating that this package has built-in type declarations

1.2.4 • Public • Published

Following are needed as pre-requiste for the project set-up

  1. Once the project is downloaded please perform the command npm install on the root path of the project downloaded folder.
    Wait for 5 mins (approx) for the node libraries to get downloaded.
  2. Clone the project https://code.siemens.com/cct-ssp/data-layer/playground/nodejs-graphql/tree/master/timeseries/timeseries and https://code.siemens.com/cct-ssp/data-layer/playground/nodejs-graphql/tree/master/timeseries2/timeseries which are the backend application graphql server talks to for data fetching.

Project set-up instruction for adding new modules


1. For adding a new modules, please create a folder (unique name) under the modules folder found under src folder and create a schema.graphql file and resolvers.ts file.
Example : For plugging in the Weather module steps as follows
a. Create a folder called Weather under modules folder
b. Create a schema file named schema.graphql and plase under the newly created Weather folder.
This file contains all the domain model for the Weather endpoint. And also the Queries, Mutation and Subscription.
c. Create a resolver file named resolvers.ts which contains the logic for all the queries, muations and subscriptions.
All the above said queries, mutations and subscriptions should be added as a const name resolvers and it should be exported by the same name.
2. All the mock for the new modules needs to be added in the file mocks.js which can be found in the mock folder.
3. By default mock would not be enabled for any of the modules, if the mock needs to be enabled please follow the below steps
a. Open the .env file which is the available in the root path of the project.
b. Create a property by following the convention weather (new created module folder name)+ _resolver_preserver_flag and assign with the value true / false.
c. By providing the above declared property as true which would enable the call to reach to the actual back end application.
d. By giving false would mock the module and return the value provided in the mocks.js file.
e. If no proper value is given in mocks.js and calling the query with mock enabled would lead to Hello World (graphql behaviour) being the mocked value where ever domain model has the string and int would be substituted with some random int value.
f. Default behaviour for mocking is false i.e. if the property is not present then the incoming request would be forwaded the actual endpoint.
4. Server application currently takes the authorization token and forwards to the endpoint for validation any.

Note: Keycloak application image can be plugged in as IAM provided with minimal code changes. As of now this has been kept as the utility pluggable module.

Readme

Keywords

none

Package Sidebar

Install

npm i kc-npm-module-d

Weekly Downloads

3

Version

1.2.4

License

ISC

Unpacked Size

8.47 kB

Total Files

11

Last publish

Collaborators

  • z00406km