-
Notifications
You must be signed in to change notification settings - Fork 162
Remove enableRegex #3097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove enableRegex #3097
Changes from all commits
232ca59
986f7ce
94df713
c0b0ce5
2c6bc5d
835a5c0
1223f8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@neo4j/graphql": major | ||
| --- | ||
|
|
||
| `enableRegex` has been removed and replaced with `MATCHES` filters in the features configuration object. See the migration guide for more information: https://neo4j.com/docs/graphql-manual/current/guides/v4-migration |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,13 +39,11 @@ interface Fields { | |
| function getWhereFields({ | ||
| typeName, | ||
| fields, | ||
| enableRegex, | ||
| isInterface, | ||
| features, | ||
| }: { | ||
| typeName: string; | ||
| fields: Fields; | ||
| enableRegex?: boolean; | ||
| isInterface?: boolean; | ||
| features?: Neo4jFeaturesSettings; | ||
| }): { [k: string]: string } { | ||
|
|
@@ -126,30 +124,25 @@ function getWhereFields({ | |
| } | ||
|
|
||
| if (["String", "ID"].includes(f.typeMeta.name)) { | ||
| const matchesSetting: boolean | undefined = features?.filters?.[f.typeMeta.name]?.MATCHES; | ||
| if (matchesSetting !== undefined) { | ||
| if (matchesSetting === true) { | ||
| res[`${f.fieldName}_MATCHES`] = { type: "String", directives: deprecatedDirectives }; | ||
| } | ||
| } else if (enableRegex) { | ||
| // TODO: This is deprecated. To be removed in 4.0.0. | ||
| res[`${f.fieldName}_MATCHES`] = { type: "String", directives: deprecatedDirectives }; | ||
| } | ||
|
|
||
| const stringWhereOperators = ["_CONTAINS", "_STARTS_WITH", "_ENDS_WITH"]; | ||
| const stringWhereOperators: Array<{ comparator: string; typeName: string }> = [ | ||
| { comparator: "_CONTAINS", typeName: f.typeMeta.name }, | ||
| { comparator: "_STARTS_WITH", typeName: f.typeMeta.name }, | ||
| { comparator: "_ENDS_WITH", typeName: f.typeMeta.name }, | ||
| ]; | ||
|
|
||
| const stringWhereOperatorsNegate = ["_NOT_CONTAINS", "_NOT_STARTS_WITH", "_NOT_ENDS_WITH"]; | ||
|
|
||
| Object.entries(features?.filters?.String || {}).forEach(([filter, enabled]) => { | ||
| if (filter === "MATCHES") { | ||
| return; | ||
| } | ||
| Object.entries(features?.filters?.[f.typeMeta.name] || {}).forEach(([filter, enabled]) => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick Consider creating a varaible for
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I think we could really make use of a I'm thinking something a bit like: features(f.typeMeta.name).hasFilter("MATCHES");This way we have a more unified way of accesing features that don't require concatenation of Thoughts? |
||
| if (enabled) { | ||
| stringWhereOperators.push(`_${filter}`); | ||
| if (filter === "MATCHES") { | ||
| stringWhereOperators.push({ comparator: `_${filter}`, typeName: "String" }); | ||
| } else { | ||
| stringWhereOperators.push({ comparator: `_${filter}`, typeName: f.typeMeta.name }); | ||
| } | ||
| } | ||
| }); | ||
| stringWhereOperators.forEach((comparator) => { | ||
| res[`${f.fieldName}${comparator}`] = { type: f.typeMeta.name, directives: deprecatedDirectives }; | ||
| stringWhereOperators.forEach(({ comparator, typeName }) => { | ||
| res[`${f.fieldName}${comparator}`] = { type: typeName, directives: deprecatedDirectives }; | ||
| }); | ||
|
|
||
| stringWhereOperatorsNegate.forEach((comparator) => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much tidier! 👏