Skip to content
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

Refactor/properties to relationship #313

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c8e1afe
Missing copyright headers
darrellwarde Jun 15, 2021
900bb4b
Point to prerelease documentation for 2.0.0 branch
darrellwarde Jun 15, 2021
20ff60f
General housekeeping before release
darrellwarde Jun 15, 2021
fb03f39
Update code comment
darrellwarde Jun 15, 2021
ec5883a
Merge remote-tracking branch 'upstream/2.0.0' into 2.0.0
darrellwarde Jun 15, 2021
9020391
Merge branch 'master' into 2.0.0
darrellwarde Jun 16, 2021
2568902
Fix TCK tests broken from merge
darrellwarde Jun 16, 2021
5965c75
fix(jwt): req.cookies might be undefined
gasp Jun 16, 2021
b479c85
Add scalars earlier in schema augmentation for use in types and inter…
darrellwarde Jun 18, 2021
dd96ac9
Merge remote-tracking branch 'upstream/2.0.0' into 2.0.0
darrellwarde Jun 18, 2021
90b388f
Merge branch 'master' into 2.0.0
darrellwarde Jun 18, 2021
ebc95e8
Changes to accomodate merge from master
darrellwarde Jun 18, 2021
af33c5e
Merge pull request #267 from gasp/fix/jwt-cookie-optional-chaining
oskarhane Jun 22, 2021
6d1853d
fix: use package json for useragent name and version (#271)
danstarns Jun 22, 2021
689c778
config: remove codeowners (#277)
danstarns Jun 22, 2021
283b179
Version update
Jun 22, 2021
1972059
Merge branch 'release/06-22-2021'
Jun 22, 2021
00871c8
fix(login): avoid confusion caused by secondary button (#265)
gasp Jun 28, 2021
502bd00
Merge branch '2.0.0' of github.com:neo4j/graphql into 2.0.0
darrellwarde Jun 29, 2021
2b1f1b3
Merge branch '2.0.0' of github.com:darrellwarde/graphql into 2.0.0
darrellwarde Jun 29, 2021
ba9ee02
fix: losing params while creating Auth Predicate (#281)
mathix420 Jun 30, 2021
6fdaeda
feat: add projection to top level cypher directive (#251)
danstarns Jun 30, 2021
5261188
Merge remote-tracking branch 'upstream/2.0.0' into 2.0.0
darrellwarde Jul 1, 2021
559cd18
Merge remote-tracking branch 'upstream/2.0.0' into 2.0.0
darrellwarde Jul 2, 2021
0107313
Merge remote-tracking branch 'upstream/2.0.0' into 2.0.0
darrellwarde Jul 5, 2021
5e51f67
Merge remote-tracking branch 'upstream/2.0.0' into 2.0.0
darrellwarde Jul 5, 2021
7e531cf
Merge remote-tracking branch 'upstream/2.0.0' into 2.0.0
darrellwarde Jul 5, 2021
662acc3
Fix for loss of scalar and field level resolvers (#297)
darrellwarde Jul 6, 2021
e55bd53
Mention double escaping for @cypher directive
darrellwarde Jul 6, 2021
1d5351d
Merge pull request #299 from darrellwarde/docs/cypher-escaping
darrellwarde Jul 6, 2021
46f64c6
Version update
Jul 6, 2021
01a7c06
Merge branch 'release/1.1.0'
Jul 6, 2021
dea402b
Merge branch 'master' into 2.0.0
darrellwarde Jul 8, 2021
4971e65
Merge remote-tracking branch 'upstream/2.0.0' into 2.0.0
darrellwarde Jul 8, 2021
5e928f6
Allows users to pass in decoded JWT (#303)
darrellwarde Jul 9, 2021
decaf85
Version update
Jul 12, 2021
e0220be
Merge branch 'release/07-12-2021'
Jul 12, 2021
7cbe049
Merge remote-tracking branch 'upstream/2.0.0' into 2.0.0
darrellwarde Jul 12, 2021
6db4f39
Merge branch 'master' into 2.0.0
darrellwarde Jul 12, 2021
43a5d63
Merge remote-tracking branch 'upstream/2.0.0' into 2.0.0
darrellwarde Jul 12, 2021
53187d1
Replace instances of "properties" with "relationship"
darrellwarde Jul 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/asciidoc/type-definitions/relationships.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ mutation CreateActor {
where: {
node: { title: "Forrest Gump" }
}
properties: {
relationship: {
roles: ["Forrest"]
}
}
Expand Down Expand Up @@ -182,7 +182,7 @@ mutation CreateMovieDirectorAndActor {
name: "Tom Hanks"
born: 1956
}
properties: {
relationship: {
roles: ["Forrest"]
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/graphql/src/schema/make-augmented-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ function makeAugmentedSchema(
name: createName,
fields: {
node: `${n.name}CreateInput!`,
...(rel.properties ? { properties: `${rel.properties}CreateInput!` } : {}),
...(rel.properties ? { relationship: `${rel.properties}CreateInput!` } : {}),
},
});

Expand Down Expand Up @@ -699,7 +699,7 @@ function makeAugmentedSchema(
: `${n.name}ConnectInput`,
}
: {}),
...(rel.properties ? { properties: `${rel.properties}CreateInput!` } : {}),
...(rel.properties ? { relationship: `${rel.properties}CreateInput!` } : {}),
},
});

Expand Down Expand Up @@ -859,7 +859,7 @@ function makeAugmentedSchema(
fields: {
node: `${n.name}CreateInput!`,
...(rel.properties
? { properties: `${rel.properties}CreateInput${anyNonNullRelProperties ? `!` : ""}` }
? { relationship: `${rel.properties}CreateInput${anyNonNullRelProperties ? `!` : ""}` }
: {}),
},
});
Expand All @@ -886,7 +886,7 @@ function makeAugmentedSchema(
? { connect: rel.typeMeta.array ? `[${n.name}ConnectInput!]` : `${n.name}ConnectInput` }
: {}),
...(rel.properties
? { properties: `${rel.properties}CreateInput${anyNonNullRelProperties ? `!` : ""}` }
? { relationship: `${rel.properties}CreateInput${anyNonNullRelProperties ? `!` : ""}` }
: {}),
},
});
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql/src/translate/create-connect-and-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function createConnectAndParams({
const relationshipName = `${baseName}_relationship`;
const inStr = relationField.direction === "IN" ? "<-" : "-";
const outStr = relationField.direction === "OUT" ? "->" : "-";
const relTypeStr = `[${connect.properties ? relationshipName : ""}:${relationField.type}]`;
const relTypeStr = `[${connect.relationship ? relationshipName : ""}:${relationField.type}]`;

if (parentNode.auth && !fromCreate) {
const whereAuth = createAuthAndParams({
Expand Down Expand Up @@ -155,13 +155,13 @@ function createConnectAndParams({
res.connects.push(`FOREACH(_ IN CASE ${nodeName} WHEN NULL THEN [] ELSE [1] END | `);
res.connects.push(`MERGE (${parentVar})${inStr}${relTypeStr}${outStr}(${nodeName})`);

if (connect.properties) {
if (connect.relationship) {
const relationship = (context.neoSchema.relationships.find(
(x) => x.properties === relationField.properties
) as unknown) as Relationship;

const setA = createSetRelationshipPropertiesAndParams({
properties: connect.properties,
properties: connect.relationship,
varName: relationshipName,
relationship,
operation: "CREATE",
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql/src/translate/create-create-and-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ function createCreateAndParams({

const inStr = relationField.direction === "IN" ? "<-" : "-";
const outStr = relationField.direction === "OUT" ? "->" : "-";
const relTypeStr = `[${create.properties ? propertiesName : ""}:${relationField.type}]`;
const relTypeStr = `[${create.relationship ? propertiesName : ""}:${relationField.type}]`;
res.creates.push(`MERGE (${varName})${inStr}${relTypeStr}${outStr}(${nodeName})`);

if (create.properties) {
if (create.relationship) {
const relationship = (context.neoSchema.relationships.find(
(x) => x.properties === relationField.properties
) as unknown) as Relationship;

const setA = createSetRelationshipPropertiesAndParams({
properties: create.properties,
properties: create.relationship,
varName: propertiesName,
relationship,
operation: "CREATE",
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql/src/translate/create-update-and-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function createUpdateAndParams({
} else {
updateStrs.push(`", "", ${apocArgs})`);
}
updateStrs.push(`YIELD value as ${relationshipVariable}_${key}${index}_properties`);
updateStrs.push(`YIELD value as ${relationshipVariable}_${key}${index}_relationship`);
res.strs.push(updateStrs.join("\n"));
}
}
Expand Down Expand Up @@ -306,9 +306,9 @@ function createUpdateAndParams({
}]${outStr}(${nodeName})`
);

if (create.properties) {
if (create.relationship) {
const setA = createSetRelationshipPropertiesAndParams({
properties: create.properties,
properties: create.relationship,
varName: propertiesName,
relationship,
operation: "CREATE",
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql/src/translate/translate-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function translateUpdate({ node, context }: { node: Node; context: Context }): [
}${index}`;
const nodeName = `${baseName}_node`;
const propertiesName = `${baseName}_relationship`;
const relTypeStr = `[${create.properties ? propertiesName : ""}:${relationField.type}]`;
const relTypeStr = `[${create.relationship ? propertiesName : ""}:${relationField.type}]`;

const createAndParams = createCreateAndParams({
context,
Expand All @@ -218,13 +218,13 @@ function translateUpdate({ node, context }: { node: Node; context: Context }): [
cypherParams = { ...cypherParams, ...createAndParams[1] };
createStrs.push(`MERGE (${varName})${inStr}${relTypeStr}${outStr}(${nodeName})`);

if (create.properties) {
if (create.relationship) {
const relationship = (context.neoSchema.relationships.find(
(x) => x.properties === relationField.properties
) as unknown) as Relationship;

const setA = createSetRelationshipPropertiesAndParams({
properties: create.properties,
properties: create.relationship,
varName: propertiesName,
relationship,
operation: "CREATE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe("Connection Resolvers", () => {
id: "${actorId}",
name: "Keanu Reeves"
},
properties: {
relationship: {
screenTime: 100
}
}]
Expand Down Expand Up @@ -201,7 +201,7 @@ describe("Connection Resolvers", () => {
id: x.toString(),
name: String.fromCharCode(x + 1 + 64) + generate({ charset: "alphabetic" }),
},
properties: {
relationship: {
screenTime: Math.floor(Math.random() * 200),
},
}));
Expand Down Expand Up @@ -237,9 +237,9 @@ describe("Connection Resolvers", () => {
title: movieTitle,
actorsConnection: {
totalCount: 20,
edges: actors.slice(0, 5).map(({ node, properties }) => ({
edges: actors.slice(0, 5).map(({ node, relationship }) => ({
node,
screenTime: properties.screenTime,
screenTime: relationship.screenTime,
cursor: expect.any(String),
})),
pageInfo: {
Expand Down Expand Up @@ -294,10 +294,10 @@ describe("Connection Resolvers", () => {
title: movieTitle,
actorsConnection: {
totalCount: 20,
edges: actors.slice(5, 10).map(({ node, properties }) => ({
edges: actors.slice(5, 10).map(({ node, relationship }) => ({
node,
cursor: expect.any(String),
screenTime: properties.screenTime,
screenTime: relationship.screenTime,
})),
pageInfo: {
hasPreviousPage: true,
Expand Down Expand Up @@ -325,10 +325,10 @@ describe("Connection Resolvers", () => {
title: movieTitle,
actorsConnection: {
totalCount: 20,
edges: actors.slice(10, 15).map(({ node, properties }) => ({
edges: actors.slice(10, 15).map(({ node, relationship }) => ({
node,
cursor: expect.any(String),
screenTime: properties.screenTime,
screenTime: relationship.screenTime,
})),
pageInfo: {
hasPreviousPage: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe("Enum Relationship Properties", () => {
actors: {
create: [
{
properties: { roleType: LEADING }
relationship: { roleType: LEADING }
node: { name: $name }
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe("Relationship properties - connect", () => {
actors: {
connect: [{
where: { node: { name: $actorName } },
properties: { screenTime: $screenTime },
relationship: { screenTime: $screenTime },
}]
}
}
Expand Down Expand Up @@ -169,7 +169,7 @@ describe("Relationship properties - connect", () => {
where: {
node: { title: $movieTitle }
},
properties: {
relationship: {
screenTime: $screenTime
}
}
Expand Down Expand Up @@ -251,7 +251,7 @@ describe("Relationship properties - connect", () => {
connect: {
actors: {
where: { node: { name: $actorName } }
properties: { screenTime: $screenTime }
relationship: { screenTime: $screenTime }
}
}
) {
Expand Down Expand Up @@ -343,7 +343,7 @@ describe("Relationship properties - connect", () => {
actedIn: {
Movie: {
where: { node: { title: $movieTitle } }
properties: { screenTime: $screenTime }
relationship: { screenTime: $screenTime }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe("Relationship properties - create", () => {
title: $movieTitle
actors: {
create: [{
properties: { screenTime: $screenTime },
relationship: { screenTime: $screenTime },
node: { name: $actorName }
}]
}
Expand Down Expand Up @@ -156,7 +156,7 @@ describe("Relationship properties - create", () => {
publications: {
Movie: {
create: [{
properties: { words: $words },
relationship: { words: $words },
node: { title: $movieTitle }
}]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mutation {
input: [
{
title: "Forrest Gump"
actors: { connect: [{ properties: { screenTime: 60 } }] }
actors: { connect: [{ relationship: { screenTime: 60 } }] }
}
]
) {
Expand Down Expand Up @@ -102,7 +102,7 @@ mutation {
connect: [
{
where: { node: { name: "Tom Hanks" } }
properties: { screenTime: 60 }
relationship: { screenTime: 60 }
}
]
}
Expand Down Expand Up @@ -173,7 +173,7 @@ this0 { .title, actorsConnection } AS this0
mutation {
updateMovies(
where: { title: "Forrest Gump" }
connect: { actors: { properties: { screenTime: 60 } } }
connect: { actors: { relationship: { screenTime: 60 } } }
) {
movies {
title
Expand Down Expand Up @@ -236,7 +236,7 @@ mutation {
connect: {
actors: {
where: { node: { name: "Tom Hanks" } }
properties: { screenTime: 60 }
relationship: { screenTime: 60 }
}
}
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mutation {
create: [
{
node: { name: "Tom Hanks" }
properties: { screenTime: 60 }
relationship: { screenTime: 60 }
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ CALL apoc.do.when(this_acted_in0 IS NOT NULL, "
SET this_acted_in0.screenTime = $updateMovies.args.update.actors[0].update.relationship.screenTime
RETURN count(*)
", "", {this_acted_in0:this_acted_in0, updateMovies: $updateMovies})
YIELD value as this_acted_in0_actors0_properties
YIELD value as this_acted_in0_actors0_relationship

RETURN this { .title } AS this
```
Expand Down Expand Up @@ -143,7 +143,7 @@ CALL apoc.do.when(this_acted_in0 IS NOT NULL, "
SET this_acted_in0.screenTime = $updateMovies.args.update.actors[0].update.relationship.screenTime
RETURN count(*)
", "", {this_acted_in0:this_acted_in0, updateMovies: $updateMovies})
YIELD value as this_acted_in0_actors0_properties
YIELD value as this_acted_in0_actors0_relationship

RETURN this { .title } AS this
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ input MovieConnectWhere {
input ActorMoviesConnectFieldInput {
where: MovieConnectWhere
connect: [MovieConnectInput!]
properties: ActedInCreateInput!
relationship: ActedInCreateInput!
}

type ActorMoviesConnection {
Expand All @@ -132,7 +132,7 @@ input ActorMoviesConnectionWhere {

input ActorMoviesCreateFieldInput {
node: MovieCreateInput!
properties: ActedInCreateInput!
relationship: ActedInCreateInput!
}

input ActorMoviesFieldInput {
Expand Down Expand Up @@ -233,7 +233,7 @@ input ActorConnectWhere {
input MovieActorsConnectFieldInput {
where: ActorConnectWhere
connect: [ActorConnectInput!]
properties: ActedInCreateInput!
relationship: ActedInCreateInput!
}

type MovieActorsConnection {
Expand All @@ -258,7 +258,7 @@ input MovieActorsConnectionWhere {

input MovieActorsCreateFieldInput {
node: ActorCreateInput!
properties: ActedInCreateInput!
relationship: ActedInCreateInput!
}

input MovieActorsFieldInput {
Expand Down
Loading