Skip to content

Commit f70eb84

Browse files
1.0.17
1 parent 4e74494 commit f70eb84

File tree

8 files changed

+4
-52
lines changed

8 files changed

+4
-52
lines changed

dist/get-allowed-query.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ function getAllowedQueryForRequest(requestQuery, allowedQueriesMap) {
1313
const firstField = operationDefinition.selectionSet.selections.find((sel) => sel.kind === 'Field');
1414
const firstFieldName = firstField ? firstField.name.value : '';
1515
const key = `${operationName ? operationName + '.' : ''}${firstFieldName}`.trim();
16-
console.log('key :>> ', key);
17-
console.log('allowedQueriesMap[key] :>> ', allowedQueriesMap[key]);
1816
return allowedQueriesMap[key] || '';
1917
}
2018
exports.getAllowedQueryForRequest = getAllowedQueryForRequest;

dist/index.d.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,6 @@ export declare class GraphQLQueryPurifier {
4545
* @private
4646
*/
4747
private loadQueries;
48-
/**
49-
* Middleware function to filter incoming GraphQL queries based on the allowed list.
50-
* If a query is not allowed, it's replaced with a minimal query.
51-
* @param {Request} req - The request object.
52-
* @param {Response} res - The response object.
53-
* @param {NextFunction} next - The next middleware function in the stack.
54-
*/
5548
/**
5649
* Middleware function to filter incoming GraphQL queries based on the allowed list.
5750
* If a query is not allowed, it's replaced with a minimal query.

dist/index.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ class GraphQLQueryPurifier {
2121
* @param {boolean} [params.debug=false] - Flag to enable logging of input/output.
2222
*/
2323
constructor({ gqlPath, allowAll = false, allowStudio = false, debug = false, }) {
24-
/**
25-
* Middleware function to filter incoming GraphQL queries based on the allowed list.
26-
* If a query is not allowed, it's replaced with a minimal query.
27-
* @param {Request} req - The request object.
28-
* @param {Response} res - The response object.
29-
* @param {NextFunction} next - The next middleware function in the stack.
30-
*/
3124
/**
3225
* Middleware function to filter incoming GraphQL queries based on the allowed list.
3326
* If a query is not allowed, it's replaced with a minimal query.

dist/merge.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
Object.defineProperty(exports, "__esModule", { value: true });
33
exports.mergeQueries = void 0;
44
const graphql_1 = require("graphql");
5-
function getFirstFieldName(operation) {
6-
const firstField = operation.selectionSet.selections.find((sel) => sel.kind === 'Field');
7-
return firstField ? firstField.name.value : undefined;
8-
}
95
function getPath(node, ancestors) {
106
const path = ancestors
117
.map((ancestor) => (ancestor.kind === 'Field' ? ancestor.name.value : null))

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphql-query-purifier",
3-
"version": "1.0.16",
3+
"version": "1.0.17",
44
"description": "A small library to match .gql queries vs user input. Removes fields from user requests that are not expected by your frontend code.",
55
"main": "./dist/index.js",
66
"author": "multipliedtwice",

src/get-allowed-query.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export function getAllowedQueryForRequest(
2121
const key = `${
2222
operationName ? operationName + '.' : ''
2323
}${firstFieldName}`.trim();
24-
console.log('key :>> ', key);
25-
console.log('allowedQueriesMap[key] :>> ', allowedQueriesMap[key]);
24+
2625
return allowedQueriesMap[key] || '';
2726
}

src/index.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import { NextFunction, Request, Response } from 'express';
22
import fs from 'fs';
3-
import {
4-
FieldNode,
5-
GraphQLError,
6-
OperationDefinitionNode,
7-
parse,
8-
} from 'graphql';
3+
import { FieldNode, OperationDefinitionNode, parse } from 'graphql';
94
import path from 'path';
105
// @ts-ignore
116
import glob from 'glob';
@@ -115,13 +110,6 @@ export class GraphQLQueryPurifier {
115110
});
116111
}
117112

118-
/**
119-
* Middleware function to filter incoming GraphQL queries based on the allowed list.
120-
* If a query is not allowed, it's replaced with a minimal query.
121-
* @param {Request} req - The request object.
122-
* @param {Response} res - The response object.
123-
* @param {NextFunction} next - The next middleware function in the stack.
124-
*/
125113
/**
126114
* Middleware function to filter incoming GraphQL queries based on the allowed list.
127115
* If a query is not allowed, it's replaced with a minimal query.

src/merge.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
1-
import {
2-
parse,
3-
print,
4-
visit,
5-
OperationDefinitionNode,
6-
FieldNode,
7-
ASTNode,
8-
} from 'graphql';
9-
function getFirstFieldName(
10-
operation: OperationDefinitionNode
11-
): string | undefined {
12-
const firstField = operation.selectionSet.selections.find(
13-
(sel) => sel.kind === 'Field'
14-
);
15-
return firstField ? (firstField as any).name.value : undefined;
16-
}
1+
import { parse, print, visit, FieldNode, ASTNode } from 'graphql';
172

183
function getPath(node: FieldNode, ancestors: ASTNode[]): string {
194
const path = ancestors

0 commit comments

Comments
 (0)