Skip to content

Commit

Permalink
Update relationship filters order
Browse files Browse the repository at this point in the history
  • Loading branch information
angrykoala committed Jul 25, 2024
1 parent 914e1b8 commit 3333c13
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 53 deletions.
4 changes: 2 additions & 2 deletions packages/graphql/src/api-v6/queryIRFactory/FilterFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ export class FilterFactory {
const relationshipAdapter = new RelationshipAdapter(relationship);

const target = relationshipAdapter.target as ConcreteEntityAdapter;
const edgeFilters = filters.edges ?? {};

return Object.entries(edgeFilters).map(([rawOperator, filter]) => {
return Object.entries(filters).map(([rawOperator, edgeFilter]) => {
const filter = edgeFilter.edges;
const relatedNodeFilters = this.createFilters({
where: filter,
relationship: relationship,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ export type NumberFilters = WithLogicalOperations<{
}>;

export type RelationshipFilters = {
edges?: {
some?: GraphQLEdgeWhere;
single?: GraphQLEdgeWhere;
all?: GraphQLEdgeWhere;
none?: GraphQLEdgeWhere;
};
some?: RelationshipEdgeWhere;
single?: RelationshipEdgeWhere;
all?: RelationshipEdgeWhere;
none?: RelationshipEdgeWhere;
};

type RelationshipEdgeWhere = {
edges: GraphQLEdgeWhere;
};

type WithLogicalOperations<T> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe("Relationship filters with all", () => {
const query = /* GraphQL */ `
query {
${Movie.plural}(
where: { node: { actors: { edges: { all: { node: { name: { equals: "Keanu" } } } } } } }
where: { node: { actors: { all: { edges: { node: { name: { equals: "Keanu" } } } } } } }
) {
connection {
edges {
Expand Down Expand Up @@ -99,7 +99,7 @@ describe("Relationship filters with all", () => {
const query = /* GraphQL */ `
query {
${Movie.plural}(
where: { node: { actors: { edges: { all: { properties: { year: { equals: 1999 } } } } } } }
where: { node: { actors: { all: { edges: { properties: { year: { equals: 1999 } } } } } } }
) {
connection {
edges {
Expand Down Expand Up @@ -133,7 +133,7 @@ describe("Relationship filters with all", () => {
const query = /* GraphQL */ `
query {
${Movie.plural}(
where: { node: { actors: { edges: { all: { OR: [{ properties: { year: { equals: 1999 } } }, { node: { name: { equals: "Keanu" } } }] } } } } }
where: { node: { actors: { all: { edges: { OR: [{ properties: { year: { equals: 1999 } } }, { node: { name: { equals: "Keanu" } } }] } } } } }
) {
connection {
edges {
Expand Down Expand Up @@ -172,7 +172,7 @@ describe("Relationship filters with all", () => {
const query = /* GraphQL */ `
query {
${Movie.plural}(
where: { node: { actors: { edges: { all: { NOT: { node: { name: { equals: "Keanu" } } } } } } } }
where: { node: { actors: { all: { edges: { NOT: { node: { name: { equals: "Keanu" } } } } } } } }
) {
connection {
edges {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe("Relationship filters with none", () => {
const query = /* GraphQL */ `
query {
${Movie.plural}(
where: { node: { actors: { edges: { none: { node: { name: { equals: "Keanu" } } } } } } }
where: { node: { actors: { none: { edges: { node: { name: { equals: "Keanu" } } } } } } }
) {
connection {
edges {
Expand Down Expand Up @@ -104,7 +104,7 @@ describe("Relationship filters with none", () => {
const query = /* GraphQL */ `
query {
${Movie.plural}(
where: { node: { actors: { edges: { none: { properties: { year: { equals: 1999 } } } } } } }
where: { node: { actors: { none: { edges: { properties: { year: { equals: 1999 } } } } } } }
) {
connection {
edges {
Expand Down Expand Up @@ -143,7 +143,7 @@ describe("Relationship filters with none", () => {
const query = /* GraphQL */ `
query {
${Movie.plural}(
where: { node: { actors: { edges: { none: { OR: [{ properties: { year: { equals: 1999 } } }, { node: { name: { equals: "Keanu" } } }] } } } } }
where: { node: { actors: { none: { edges: { OR: [{ properties: { year: { equals: 1999 } } }, { node: { name: { equals: "Keanu" } } }] } } } } }
) {
connection {
edges {
Expand Down Expand Up @@ -177,7 +177,7 @@ describe("Relationship filters with none", () => {
const query = /* GraphQL */ `
query {
${Movie.plural}(
where: { node: { actors: { edges: { none: { NOT: { node: { name: { equals: "Keanu" } } } } } } } }
where: { node: { actors: { none: { edges: { NOT: { node: { name: { equals: "Keanu" } } } } } } } }
) {
connection {
edges {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe("Relationship filters with single", () => {
const query = /* GraphQL */ `
query {
${Movie.plural}(
where: { node: { actors: { edges: { single: { node: { name: { equals: "Keanu" } } } } } } }
where: { node: { actors: { single: { edges: { node: { name: { equals: "Keanu" } } } } } } }
) {
connection {
edges {
Expand Down Expand Up @@ -101,7 +101,7 @@ describe("Relationship filters with single", () => {
const query = /* GraphQL */ `
query {
${Movie.plural}(
where: { node: { actors: { edges: { single: { properties: { year: { equals: 1999 } } } } } } }
where: { node: { actors: { single: { edges: { properties: { year: { equals: 1999 } } } } } } }
) {
connection {
edges {
Expand Down Expand Up @@ -135,7 +135,7 @@ describe("Relationship filters with single", () => {
const query = /* GraphQL */ `
query {
${Movie.plural}(
where: { node: { actors: { edges: { single: { OR: [{ properties: { year: { equals: 1999 } } }, { node: { name: { equals: "Keanu" } } }] } } } } }
where: { node: { actors: { single: { edges: { OR: [{ properties: { year: { equals: 1999 } } }, { node: { name: { equals: "Keanu" } } }] } } } } }
) {
connection {
edges {
Expand Down Expand Up @@ -174,7 +174,7 @@ describe("Relationship filters with single", () => {
const query = /* GraphQL */ `
query {
${Movie.plural}(
where: { node: { actors: { edges: { single: { NOT: { node: { name: { equals: "Keanu" } } } } } } } }
where: { node: { actors: { single: { edges: { NOT: { node: { name: { equals: "Keanu" } } } } } } } }
) {
connection {
edges {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe("Relationship filters with some", () => {
const query = /* GraphQL */ `
query {
${Movie.plural}(
where: { node: { actors: { edges: { some: { node: { name: { equals: "Keanu" } } } } } } }
where: { node: { actors: { some: { edges: { node: { name: { equals: "Keanu" } } } } } } }
) {
connection {
edges {
Expand Down Expand Up @@ -104,7 +104,7 @@ describe("Relationship filters with some", () => {
const query = /* GraphQL */ `
query {
${Movie.plural}(
where: { node: { actors: { edges: { some: { properties: { year: { equals: 1999 } } } } } } }
where: { node: { actors: { some: { edges: { properties: { year: { equals: 1999 } } } } } } }
) {
connection {
edges {
Expand Down Expand Up @@ -143,7 +143,7 @@ describe("Relationship filters with some", () => {
const query = /* GraphQL */ `
query {
${Movie.plural}(
where: { node: { actors: { edges: { some: { OR: [{ properties: { year: { equals: 1999 } } }, { node: { name: { equals: "Keanu" } } }] } } } } }
where: { node: { actors: { some: { edges: { OR: [{ properties: { year: { equals: 1999 } } }, { node: { name: { equals: "Keanu" } } }] } } } } }
) {
connection {
edges {
Expand Down Expand Up @@ -187,7 +187,7 @@ describe("Relationship filters with some", () => {
const query = /* GraphQL */ `
query {
${Movie.plural}(
where: { node: { actors: { edges: { some: { NOT: { node: { name: { equals: "Keanu" } } } } } } } }
where: { node: { actors: { some: { edges: { NOT: { node: { name: { equals: "Keanu" } } } } } } } }
) {
connection {
edges {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe("https://github.com/neo4j/graphql/issues/190", () => {
test("Example 1", async () => {
const query = /* GraphQL */ `
query {
${User.plural}(where: { node: { demographics: { edges: { some: {node: { type: { equals: "Gender" }, value: { equals: "Female" } } } } } } }) {
${User.plural}(where: { node: { demographics: { some: { edges: {node: { type: { equals: "Gender" }, value: { equals: "Female" } } } } } } }) {
connection {
edges {
node {
Expand Down Expand Up @@ -141,8 +141,8 @@ describe("https://github.com/neo4j/graphql/issues/190", () => {
where: {
node: {
demographics: {
edges: {
some: {
some: {
edges: {
node: {
OR: [{ type: {equals: "Gender"}, value:{equals: "Female"} }, { type: {equals: "State"} }, { type: {equals: "Age"} }]
}
Expand Down
20 changes: 10 additions & 10 deletions packages/graphql/tests/api-v6/integration/issues/582.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ describe("https://github.com/neo4j/graphql/issues/582", () => {
node: {
type: { equals: "Cat" },
children: {
edges: {
some: {
some: {
edges: {
node: {
type: { equals: "Dog" },
parents: {
edges: {
some: {
some: {
edges: {
node: {
type: { equals: "Bird" },
},
Expand Down Expand Up @@ -119,18 +119,18 @@ describe("https://github.com/neo4j/graphql/issues/582", () => {
node: {
type: { equals: "Cat" },
children: {
edges: {
some: {
some: {
edges: {
node: {
type: { equals: "Dog" },
parents: {
edges: {
some: {
some: {
edges: {
node: {
type: { equals: "Bird" },
children: {
edges: {
some: {
some: {
edges: {
node: {
type: { equals: "Fish" },
},
Expand Down
8 changes: 4 additions & 4 deletions packages/graphql/tests/api-v6/tck/filters/nested/all.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe("Nested Filters with all", () => {
test("query nested relationship with all filter", async () => {
const query = /* GraphQL */ `
query {
movies(where: { node: { actors: { edges: { all: { node: { name: { equals: "Keanu" } } } } } } }) {
movies(where: { node: { actors: { all: { edges: { node: { name: { equals: "Keanu" } } } } } } }) {
connection {
edges {
node {
Expand Down Expand Up @@ -91,7 +91,7 @@ describe("Nested Filters with all", () => {
test("query nested relationship properties with all filter", async () => {
const query = /* GraphQL */ `
query {
movies(where: { node: { actors: { edges: { all: { properties: { year: { equals: 1999 } } } } } } }) {
movies(where: { node: { actors: { all: { edges: { properties: { year: { equals: 1999 } } } } } } }) {
connection {
edges {
node {
Expand Down Expand Up @@ -142,8 +142,8 @@ describe("Nested Filters with all", () => {
where: {
node: {
actors: {
edges: {
all: {
all: {
edges: {
OR: [
{ node: { name: { equals: "Keanu" } } }
{ node: { name: { endsWith: "eeves" } } }
Expand Down
8 changes: 4 additions & 4 deletions packages/graphql/tests/api-v6/tck/filters/nested/none.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe("Nested Filters with none", () => {
test("query nested relationship with none filter", async () => {
const query = /* GraphQL */ `
query {
movies(where: { node: { actors: { edges: { none: { node: { name: { equals: "Keanu" } } } } } } }) {
movies(where: { node: { actors: { none: { edges: { node: { name: { equals: "Keanu" } } } } } } }) {
connection {
edges {
node {
Expand Down Expand Up @@ -88,7 +88,7 @@ describe("Nested Filters with none", () => {
test("query nested relationship properties with none filter", async () => {
const query = /* GraphQL */ `
query {
movies(where: { node: { actors: { edges: { none: { properties: { year: { equals: 1999 } } } } } } }) {
movies(where: { node: { actors: { none: { edges: { properties: { year: { equals: 1999 } } } } } } }) {
connection {
edges {
node {
Expand Down Expand Up @@ -136,8 +136,8 @@ describe("Nested Filters with none", () => {
where: {
node: {
actors: {
edges: {
some: {
some: {
edges: {
OR: [
{ node: { name: { equals: "Keanu" } } }
{ node: { name: { endsWith: "eeves" } } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe("Nested Filters with single", () => {
test("query nested relationship with single filter", async () => {
const query = /* GraphQL */ `
query {
movies(where: { node: { actors: { edges: { single: { node: { name: { equals: "Keanu" } } } } } } }) {
movies(where: { node: { actors: { single: { edges: { node: { name: { equals: "Keanu" } } } } } } }) {
connection {
edges {
node {
Expand Down Expand Up @@ -85,7 +85,7 @@ describe("Nested Filters with single", () => {
test("query nested relationship properties with single filter", async () => {
const query = /* GraphQL */ `
query {
movies(where: { node: { actors: { edges: { single: { properties: { year: { equals: 1999 } } } } } } }) {
movies(where: { node: { actors: { single: { edges: { properties: { year: { equals: 1999 } } } } } } }) {
connection {
edges {
node {
Expand Down Expand Up @@ -130,8 +130,8 @@ describe("Nested Filters with single", () => {
where: {
node: {
actors: {
edges: {
single: {
single: {
edges: {
OR: [
{ node: { name: { equals: "Keanu" } } }
{ node: { name: { endsWith: "eeves" } } }
Expand Down
8 changes: 4 additions & 4 deletions packages/graphql/tests/api-v6/tck/filters/nested/some.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe("Nested Filters with some", () => {
test("query nested relationship with some filter", async () => {
const query = /* GraphQL */ `
query {
movies(where: { node: { actors: { edges: { some: { node: { name: { equals: "Keanu" } } } } } } }) {
movies(where: { node: { actors: { some: { edges: { node: { name: { equals: "Keanu" } } } } } } }) {
connection {
edges {
node {
Expand Down Expand Up @@ -88,7 +88,7 @@ describe("Nested Filters with some", () => {
test("query nested relationship properties with some filter", async () => {
const query = /* GraphQL */ `
query {
movies(where: { node: { actors: { edges: { some: { properties: { year: { equals: 1999 } } } } } } }) {
movies(where: { node: { actors: { some: { edges: { properties: { year: { equals: 1999 } } } } } } }) {
connection {
edges {
node {
Expand Down Expand Up @@ -136,8 +136,8 @@ describe("Nested Filters with some", () => {
where: {
node: {
actors: {
edges: {
some: {
some: {
edges: {
OR: [
{ node: { name: { equals: "Keanu" } } }
{ node: { name: { endsWith: "eeves" } } }
Expand Down

0 comments on commit 3333c13

Please sign in to comment.