UNPKG

@neo4j/graphql

Version:

A GraphQL to Cypher query execution layer for Neo4j and JavaScript GraphQL implementations

48 lines 2.14 kB
"use strict"; /* * Copyright (c) "Neo4j" * Neo4j Sweden AB [http://neo4j.com] * * This file is part of Neo4j. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.aggregationFieldRegEx = void 0; exports.parseWhereField = parseWhereField; exports.parseAggregationWhereFields = parseAggregationWhereFields; // This regex is only valid for the non generic operators const whereRegEx = /(?<prefix>\w*\.)?(?<fieldName>[_A-Za-z]\w*?)(?<isConnection>Connection)?(?<isAggregate>Aggregate)?(?:_(?<operator>IN|INCLUDES|MATCHES|CONTAINS|STARTS_WITH|ENDS_WITH|EQ|LT|LTE|GT|GTE|DISTANCE|ALL|NONE|SINGLE|SOME))?$/; function parseWhereField(field) { const match = whereRegEx.exec(field); const matchGroups = match?.groups; const operator = match?.groups?.operator; return { fieldName: matchGroups.fieldName, isAggregate: Boolean(matchGroups.isAggregate), operator, prefix: matchGroups.prefix, isConnection: Boolean(matchGroups.isConnection), }; } exports.aggregationFieldRegEx = /(?<fieldName>[_A-Za-z]\w*?)(?:_(?<aggregationOperator>AVERAGE|MAX|MIN|SUM|SHORTEST|LONGEST))?(?:_LENGTH)?(?:_(?<logicalOperator>EQUAL|EQ|GT|GTE|LT|LTE|IN))?$/; function parseAggregationWhereFields(field) { const match = exports.aggregationFieldRegEx.exec(field); const matchGroups = match?.groups; return { fieldName: matchGroups.fieldName, aggregationOperator: matchGroups.aggregationOperator, logicalOperator: matchGroups.logicalOperator, }; } //# sourceMappingURL=parse-where-field.js.map