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/union arguments #304

Merged
merged 49 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 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
d5eb30d
checkpoint: commit all changes to date - NOT WORKING
danstarns Jul 7, 2021
3f7bdca
Committing before merging in 2.0.0 changes
darrellwarde Jul 7, 2021
ace7ca9
Merge remote-tracking branch 'upstream/2.0.0' into refactor/union-arg…
darrellwarde Jul 7, 2021
9141b85
Union connect and test needs fixing
darrellwarde Jul 7, 2021
62bdeaf
Add .huskyrc back
darrellwarde Jul 7, 2021
dea402b
Merge branch 'master' into 2.0.0
darrellwarde Jul 8, 2021
c1f9e7e
Merge branch '2.0.0' into refactor/union-arguments
darrellwarde Jul 8, 2021
4971e65
Merge remote-tracking branch 'upstream/2.0.0' into 2.0.0
darrellwarde Jul 8, 2021
22e46d5
Merge branch '2.0.0' into refactor/union-arguments
darrellwarde Jul 8, 2021
94bff67
Reformat schema TCK tests for better diff
darrellwarde Jul 8, 2021
7764775
Reorganise schema TCK for better diff
darrellwarde Jul 8, 2021
501857b
Create union input types in a map
darrellwarde Jul 8, 2021
93895ed
Various work, including nested connects and disconnects for unions, f…
darrellwarde Jul 8, 2021
c10174b
Documentation changes
darrellwarde Jul 9, 2021
4e14d57
Fix structure of nested creates for unions, and add tests for nested …
darrellwarde Jul 9, 2021
077bec2
Fix where input for nested update
darrellwarde Jul 9, 2021
46f261b
Add integration tests for multiple union create/update
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
2 changes: 1 addition & 1 deletion docs/asciidoc/guides/2.0.0-migration/mutations.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

The most broadly affected area of functionality by the 2.0.0 upgrade are the nested operations of Mutations, to faciliate the mutation of and filtering on relationship properties.

The examples in this section will be based off the following type definitions (which have been migrated over to `@neo4j/graphql` syntax):
The examples in this section will be based off the following type definitions:

[source, graphql]
----
Expand Down
94 changes: 94 additions & 0 deletions docs/asciidoc/guides/2.0.0-migration/unions.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
[[rel-migration-unions]]
= Unions

The structure of input types for union queries and mutations have been changed for user friendliness, and a more consistent API.

The examples in this section will be based off the following type definitions:

[source, graphql]
----
type Actor {
name: String!
actedIn: [Production!]! @relationship(type: "ACTED_IN", direction: OUT)
}

type Movie {
title: String!
actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN)
}

type Series {
title: String!
actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN)
}

union Production = Movie | Series
----

Essentially, field names which were previously of template `${unionFieldName}_${concreteType}` (for example, "actedIn_Movie") are now an object, with the field name at the top, and the member types under it.

For example, a Mutation which would have previously been:

[source, graphql]
----
mutation {
createActors(
input: [
{
name: "Tom Hiddleston"
actedIn_Movie: {
create: [
{
title: "The Avengers"
}
]
}
actedIn_Series: {
create: [
{
title: "Loki"
}
]
}
}
]
)
}
----

Will now be:

[source, graphql]
----
mutation {
createActors(
input: [
{
name: "Tom Hiddleston"
actedIn: {
Movie: {
create: [
{
node: {
title: "The Avengers"
}
}
]
}
Series: {
create: [
{
node: {
title: "Loki"
}
}
]
}
}
}
]
)
}
----

Note the change in structure for union input, but also the additional `node` level which enables the use of relationship properties. These changes are consistent across all operations, including `where`.
113 changes: 69 additions & 44 deletions docs/asciidoc/type-definitions/unions-and-interfaces.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,93 +5,118 @@ Unions and interfaces are abstract GraphQL types that enable a schema field to r

[[type-definitions-unions-and-interfaces-union-types]]
== Union Types
Neo4j GraphQL supports the use of Unions on a `@relationship` field.

=== Example
The following schema defines a `User` type, that has a relationship(`HAS_CONTENT`), of type `[Content]`. `Content` is of type `union` representing either `Blog` or `Post`.
The Neo4j GraphQL Library supports the use of unions on relationship fields. For example, the following schema defines a `User` type, that has a relationship `HAS_CONTENT`, of type `[Content]`. `Content` is of type `union` representing either a `Blog` or a `Post`.

[source, graphql]
----
union Content = Blog | Post

type Blog {
title: String
posts: [Post] @relationship(type: "HAS_POST", direction: OUT)
title: String
posts: [Post] @relationship(type: "HAS_POST", direction: OUT)
}

type Post {
content: String
content: String
}

type User {
name: String
content: [Content] @relationship(type: "HAS_CONTENT", direction: OUT)
name: String
content: [Content] @relationship(type: "HAS_CONTENT", direction: OUT)
}
----

Below you can find some examples of how queries and mutations work with this example.

=== Querying a union
The below query gets the user and their content;

The Neo4j GraphQL Library only returns union members which have inline fragments in your selection set.

For example, the following will return users and only their blogs:

[source, graphql]
----
query GetUsersWithContent {
users {
name
content {
... on Blog {
title
posts {
content
query GetUsersWithBlogs {
users {
name
content {
... on Blog {
title
posts {
content
}
}
}
... on Post {
content
}
}
----

Whilst the query below will return both the blogs and posts of users:

[source, graphql]
----
query GetUsersWithAllContent {
users {
name
content {
... on Blog {
title
posts {
content
}
}
... on Post {
content
}
}
}
}
}
----

=== Creating a union
The below mutation creates the user and their content;

The below mutation creates the user and their content:

[source, graphql]
----
mutation CreateUserAndContent {
createUsers(input: [
{
name: "Dan"
content_Blog: {
create: [
{
node: {
title: "My Cool Blog"
posts: {
create: [
{
node: {
content: "My Cool Post"
}
createUsers(
input: [
{
name: "Dan"
content: {
Blog: {
create: [
{
node: {
title: "My Cool Blog"
posts: {
create: [
{
node: {
content: "My Cool Post"
}
}
]
}
]
}
}
}
]
}
]
}
}
]
) {
users {
name
}
]
) {
users {
name
}
}
}

----


== Interface Types

Using interface types will give you no real database support therefore no; query, update, delete, filter support. But instead used as a language feature to safeguard your schema. Great for when dealing with repetitive or large schemas you can essentially put "The side railings up".
Using interface types will give you no database support, therefore there is no support for querying, updating, deleting, filtering. But instead used as a language feature to safeguard your schema. Great for when dealing with repetitive or large schemas you can essentially put "The side railings up".
danstarns marked this conversation as resolved.
Show resolved Hide resolved
Loading