From 27e1414476efe74a8264ffefa0396b70cc396318 Mon Sep 17 00:00:00 2001 From: Dmitry Ostrikov Date: Fri, 29 Mar 2024 10:10:16 +0400 Subject: [PATCH 1/2] feat(graphql): introduce GraphQL package closes #237 --- packages/graphql/README.md | 29 +++++++++++++++++ packages/graphql/jest.config.js | 14 ++++++++ packages/graphql/package.json | 48 ++++++++++++++++++++++++++++ packages/graphql/src/index.ts | 0 packages/graphql/tsconfig.build.json | 9 ++++++ packages/graphql/tsconfig.json | 8 +++++ tsconfig.json | 1 + 7 files changed, 109 insertions(+) create mode 100644 packages/graphql/README.md create mode 100644 packages/graphql/jest.config.js create mode 100644 packages/graphql/package.json create mode 100644 packages/graphql/src/index.ts create mode 100644 packages/graphql/tsconfig.build.json create mode 100644 packages/graphql/tsconfig.json diff --git a/packages/graphql/README.md b/packages/graphql/README.md new file mode 100644 index 00000000..715fed7d --- /dev/null +++ b/packages/graphql/README.md @@ -0,0 +1,29 @@ +# @har-sdk/graphql + +[![Maintainability](https://api.codeclimate.com/v1/badges/4acaec95c82465cb2c3d/maintainability)](https://codeclimate.com/github/NeuraLegion/har-sdk/maintainability) +[![Test Coverage](https://api.codeclimate.com/v1/badges/4acaec95c82465cb2c3d/test_coverage)](https://codeclimate.com/github/NeuraLegion/har-sdk/test_coverage) +[![Build Status](https://github.com/NeuraLegion/har-sdk/actions/workflows/auto-build.yml/badge.svg?branch=master)](https://github.com/NeuraLegion/har-sdk/actions/workflows/auto-build.yml?query=branch%3Amaster+event%3Apush) +[![NPM Downloads](https://img.shields.io/npm/dw/@har-sdk/graphql?label=NPM%20Downloads)](https://www.npmjs.com/package/@har-sdk/graphql) + +Transform your [GraphQL introspection](https://spec.graphql.org/draft/#sec-Introspection) or [GraphQL schema collection](https://spec.graphql.org/draft) into a series of [HAR request objects](http://www.softwareishard.com/blog/har-12-spec/#request). This can be useful for a variety of purposes, such as analyzing network performance and debugging web applications. + +- Automatically generates fake data for all parameters +- Simple and easy-to-use API. +- Supports variety of community adopted [custom SCALAR](https://spec.graphql.org/draft/#sec-Scalars.Custom-Scalars) types out of the box. +- Supports [GraphQL multipart request specification](https://github.com/jaydenseric/graphql-multipart-request-spec). + +With this library, you can easily generate requests with fake data to test your API using [AutoCannon](https://github.com/mcollina/autocannon#readme) or [DevTools](https://developer.chrome.com/blog/new-in-devtools-62/#har-imports). + +## Setup + +To install the library, run the following command: + +```bash +$ npm i --save @har-sdk/graphql +``` + +## License + +Copyright © 2024 [Bright Security](https://brightsec.com/). + +This project is licensed under the MIT License - see the [LICENSE file](https://github.com/NeuraLegion/har-sdk/blob/master/LICENSE) for details. diff --git a/packages/graphql/jest.config.js b/packages/graphql/jest.config.js new file mode 100644 index 00000000..f894cc09 --- /dev/null +++ b/packages/graphql/jest.config.js @@ -0,0 +1,14 @@ +module.exports = { + displayName: 'graphql', + globals: { + 'ts-jest': { + tsconfig: '/tsconfig.json' + } + }, + transform: { + '^.+\\.[tj]s$': 'ts-jest' + }, + moduleFileExtensions: ['ts', 'js', 'json'], + coverageDirectory: '../../coverage/graphql', + preset: '../../jest.preset.js' +}; diff --git a/packages/graphql/package.json b/packages/graphql/package.json new file mode 100644 index 00000000..438d76ca --- /dev/null +++ b/packages/graphql/package.json @@ -0,0 +1,48 @@ +{ + "name": "@har-sdk/graphql", + "version": "0.0.0", + "private": false, + "repository": { + "type": "git", + "url": "git+https://github.com/NeuraLegion/har-sdk.git" + }, + "author": { + "name": "Artem Derevnjuk", + "email": "artem.derevnjuk@neuralegion.com" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/NeuraLegion/har-sdk/issues" + }, + "publishConfig": { + "access": "public" + }, + "files": [ + "dist/**" + ], + "keywords": [ + "graphql", + "har", + "api" + ], + "main": "./dist/bundle.umd.js", + "module": "./dist/bundle.esm5.js", + "es2015": "./dist/index.js", + "types": "./dist/index.d.ts", + "homepage": "https://github.com/NeuraLegion/har-sdk/tree/master/packages/graphql#readme", + "scripts": { + "prebuild": "npm run compile -- --clean", + "build": "npm run compile && npm run bundle", + "bundle": "rollup -c ../../rollup.config.js", + "lint": "eslint --ignore-path ../../.eslintignore .", + "format": "prettier --ignore-path ../../.prettierignore --check .", + "compile": "tsc -b tsconfig.build.json", + "test": "cross-env NODE_ENV=test jest", + "coverage": "cross-env NODE_ENV=test jest --coverage" + }, + "dependencies": { + "@har-sdk/core": "*", + "tslib": "^2.3.1" + }, + "devDependencies": {} +} diff --git a/packages/graphql/src/index.ts b/packages/graphql/src/index.ts new file mode 100644 index 00000000..e69de29b diff --git a/packages/graphql/tsconfig.build.json b/packages/graphql/tsconfig.build.json new file mode 100644 index 00000000..46b076d1 --- /dev/null +++ b/packages/graphql/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.build.json", + "compilerOptions": { + "outDir": "./dist", + "declarationDir": "./dist" + }, + "include": ["src/**/*"], + "exclude": ["src/**/*.spec.ts", "tests/**/*"] +} diff --git a/packages/graphql/tsconfig.json b/packages/graphql/tsconfig.json new file mode 100644 index 00000000..727c4e7b --- /dev/null +++ b/packages/graphql/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "baseUrl": ".", + "rootDir": "." + }, + "include": ["src/**/*", "tests/**/*", "tests/**/*.json"] +} diff --git a/tsconfig.json b/tsconfig.json index 14d9bb22..d05c95e2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,6 +17,7 @@ { "path": "packages/oas" }, { "path": "packages/openapi-sampler" }, { "path": "packages/postman" }, + { "path": "packages/graphql" }, { "path": "packages/validator" }, { "path": "packages/types" }, { "path": "packages/editor" }, From f79f526af7d8afd63b71791a1f5ea07d85f839b6 Mon Sep 17 00:00:00 2001 From: Dmitry Ostrikov Date: Fri, 29 Mar 2024 13:23:53 +0400 Subject: [PATCH 2/2] feat(graphql): allow jest to pass without tests closes #237 --- packages/graphql/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/graphql/package.json b/packages/graphql/package.json index 438d76ca..3fbec7d2 100644 --- a/packages/graphql/package.json +++ b/packages/graphql/package.json @@ -37,7 +37,7 @@ "lint": "eslint --ignore-path ../../.eslintignore .", "format": "prettier --ignore-path ../../.prettierignore --check .", "compile": "tsc -b tsconfig.build.json", - "test": "cross-env NODE_ENV=test jest", + "test": "cross-env NODE_ENV=test jest --passWithNoTests", "coverage": "cross-env NODE_ENV=test jest --coverage" }, "dependencies": {