1.0.0 • Published 1 year ago

readiness-gql v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Readiness Graphql Server

The repo will be serving as a single middleware for all frontend apps to query Readiness services.

Requirements:

  1. node >= 10.0.0
  2. npm >= 6.4.0

Preferred node 12

nvm use 12

How to develop in the repo:

  1. master branch is the head branch. every commit needs to be merged through a PR to be approved by 2 reviewers at least.
  2. Define your schema in src/schemas directory. use .schema file for defining and extending the schema.
  3. Export your schema through index.ts files for corresponding division. (if you are defining new schema division, import and define that in schemas/index.ts)
  4. To define the types and resolvers types for your schema, do

    npm run generate

  5. To write resolvers, check src/resolvers. use the same directory structure as schemas for readability.
  6. right now resolvers --depends-upon--> data-loaders --depends-upon--> apiClients. (refer to the same guide)
  7. Refrain yourself from coding with anytype or in nodeJs directly. use strict types everywhere with typescript.
  8. Define default values for your environment variables in .env file(this will ignored while pushing to repo.) in the defined format below:
     NODE_ENV="development"
     MOCK="true"
     CONTENT_ENGINE_URL="http://ce.internal.checklist.mindtickle.com:80"

How to build the repo:

npm run build

If NODE_ENV="development", webpack hot reloading will be automatically enabled. Then in a new shell, run the following

How to run the built code:

npm run start

Server should start at : http://localhost:4000/graphql

Sample query

fragment value on ConfigValue{
  ... on BoolValue{
    boolValue
  }
  ... on StringValue{
    stringValue
  }
}
fragment config on Config{
	key,
  value{...value}
}

fragment request on Request{
  method,
	host,
	pathname,
	headers{...config},
	query{...config},
	params{...config},
  ... on PostRequest{
    body{...config}
  }
}
query{
  widget{
    listDataSources(pagination:{from:0,size:10}){
      total
      data{
        id
        request{...request}
      }
    }
  }
}

Sample Mutation

mutation($input:DataSourceInput!){
  dataSource{
    createDataSource(input: $input){
      name,
      isActive
    }
  }
}

# Query Variables - 
{
  "input":{
    "name": "data1",
    "request": {
      "host": "https://mindtickle.com/",
      "method": "GET",
      "pathname": "graphql"
    }
  }
}
  

How to run the tests in repo:

npm run test

How to temporarily supress audit vunrabilities

package.json scripts => audit change to

node node_modules/better-npm-audit audit -i 1179

Troubleshooting

Invalid regular expression: /\${(?A-Z0-9_+)(\:((?^\:+)|(\"(?^\"+)\")))?}/: Invalid group

Check node version. Use node >= 10.0.0

nvm use 12