Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
:description: This page describes how to set up authorization features in the Neo4j GraphQL Library.
= Authorization

Authorization rules cover what specific data a generated Cypher query is executed against.
They use predicates to evaluate the Cypher generated from a GraphQL query, thus allowing or disallowing execution within the context of nodes and their properties.
Authorization rules cover to what specific data a generated Cypher query is executed against.
They use predicates to evaluate the Cypher generated from a GraphQL query, thus allowing or not execution within the context of nodes and their properties.

All authorization rules have an implied requirement for authentication, given that the rules are normally evaluated against values in the JWT payload.

Expand Down Expand Up @@ -63,7 +63,7 @@ type User @authorization(validate: [
Authentication is implicitly required for every authorization check by default, but this can be disabled on a per-rule basis.
This could be the case, for instance, when a node has a property which flags whether the node should be public or not.

For instance, in the case where some `Post` nodes are private and belong to a particular `User`, while other `Post` nodes are public and readable by any user, here is how to set this up:
For instance, in case `Post` nodes might be private and belong to a particular `User`, or be public and readable by any user, here is how to set this up:

[source, graphql, indent=0]
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ auth/authorization/allow.adoc, auth/authorization/bind.adoc, auth/authorization/
auth/authorization/where.adoc, guides/v4-migration/authorization.adoc

[WARNING]
===
====
The `@auth` directive has been replaced by `@authentication` and `@authorization`.
See the xref::migration/v4-migration/authorization.adoc[Migration guide] for details on how to upgrade.
===
====

* xref::authentication-and-authorization/authentication.adoc[Authentication] - Explicit authentication, configured using the `@authentication` directive.
* xref::authentication-and-authorization/authorization.adoc[Authorization] - Authorization rules set using the `@authorization` directive.
Expand Down
41 changes: 23 additions & 18 deletions modules/ROOT/pages/integrations/apollo-federation.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[[apollo-federation]]
:description: This guide shows how to create a subgraph using the Neo4j GraphQL Library.
= Apollo Federation
:page-aliases: guides/apollo-federation.adoc
:description: This guide shows how to create a subgraph using the Neo4j GraphQL Library, for composition into a supergraph using Apollo Federation.
Expand Down Expand Up @@ -65,18 +66,19 @@ npm pkg set type="module"
----
+
[NOTE]
===
====
This how-to guide sets up the project using ES Modules, which allows the usage of features such as top-level `await`.
===
====

. Choose TypeScript or JavaScript to proceed with the setup:
+

[.tabbed-example]
====

[.include-with-Typescript]
=====
. Create a `src` directory with an empty `index.ts` file to contain the entrypoint to your code:

. Create a src directory with an empty index.ts file to contain the entrypoint to your code:
+
[source, bash]
----
Expand All @@ -91,14 +93,14 @@ touch src/index.ts
npm install --save-dev typescript @types/node @tsconfig/node-lts
----
+
. Create an empty `tsconfig.json` file containing the compiler configuration for TypeScript:
. Create an empty tsconfig.json file containing the compiler configuration for TypeScript:
+
[source, bash]
----
touch tsconfig.json
----
+
. Add the following configuration to the `tsconfig.json` file:
. Add the following configuration to the tsconfig.json file:
+
[source, json]
----
Expand All @@ -112,12 +114,12 @@ touch tsconfig.json
----
+
[NOTE]
===
This configuration extends the https://github.com/tsconfig/bases#node-lts-tsconfigjson[community base for Node.js LTS], provided by the `@tsconfig/node-lts` package installed above.
======
This configuration extends the https://github.com/tsconfig/bases#node-lts-tsconfigjson[community base for Node.js LTS], provided by the @tsconfig/node-lts package installed above.
For more information on the available options, see the https://www.typescriptlang.org/tsconfig[TypeScript Compiler docs].
===
======
+
. Replace the default `scripts` entry in your `package.json` file with the following:
. Replace the default scripts entry in your package.json file with the following:
+
[source, json]
----
Expand All @@ -134,16 +136,17 @@ For more information on the available options, see the https://www.typescriptlan

[.include-with-JavaScript]
=====
. Create a `src` directory with an empty `index.js` file to contain the entrypoint to your code:
+

Create a `src` directory with an empty `index.js` file to contain the entrypoint to your code:

[source, bash]
----
mkdir src
touch src/index.js
----
+
. Replace the default `scripts` entry in your `package.json` file with the following:
+

Replace the default `scripts` entry in your `package.json` file with the following:

[source, json]
----
{
Expand All @@ -155,7 +158,9 @@ touch src/index.js
}
----
=====

====

+
. This guide requires the installation of the following dependencies:
+
Expand Down Expand Up @@ -190,10 +195,10 @@ const typeDefs = `#graphql
----

[NOTE]
===
====
This example only includes the Federation `@key` directive.
To use more https://www.apollographql.com/docs/federation/federated-types/federated-directives[Federation directives], add them to the `import` array.
===
====

== Define an entity

Expand Down Expand Up @@ -269,4 +274,4 @@ For further iteration, this subgraph can also be composed into a supergraph.
Check Apollo's guides for more instructions:

* https://www.apollographql.com/docs/federation/quickstart/studio-composition[Composition in Apollo Studio]
* https://www.apollographql.com/docs/federation/quickstart/local-composition[Local composition]
* https://www.apollographql.com/docs/federation/quickstart/local-composition[Local composition]
22 changes: 11 additions & 11 deletions modules/ROOT/pages/subscriptions/events.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Changes made directly to the database or using the xref::type-definitions/direct
== `CREATE`

Subscriptions to `CREATE` events listen *only* to newly created nodes, not new relationships.
In this case, a new event is triggered for each new node, containing its properties.
In this occasion, a new event is triggered for each new node, containing its properties.

This action is performed with the top-level subscription `[type]Created`, which contains the following fields:

Expand Down Expand Up @@ -160,9 +160,9 @@ subscription {
Subscriptions to `CREATE_RELATIONSHIP` events listen for newly created relationships to a node of the specified type.

[NOTE]
===
====
This subscription operation is **only** available for types that define relationship fields.
===
====

== `CREATE_RELATIONSHIP`

Expand All @@ -175,10 +175,10 @@ These events:
* Contain the properties of the nodes connected through the relationship, as well as the properties of the new relationship, if any.

[NOTE]
===
====
Connected nodes that may or may not have previously existed are not covered by this subscription.
To subscribe to these nodes' updates, use the xref:subscriptions/events.adoc#_create[`CREATE`] or the xref:subscriptions/events.adoc#_update[`UPDATE`] subscription.
===
====

Subscriptions to `CREATE_RELATIONSHIP` events can be made with the top-level subscription `[type]RelationshipCreated`, which contains the following fields:

Expand All @@ -192,10 +192,10 @@ While any event unrelated to `relationshipFieldName` should be `null`, the ones
Only top-level properties, without relationships, are available and they are the properties that already existed before the `CREATE_RELATIONSHIP` operation took place.

[NOTE]
===
====
Irrespective of the relationship direction in the database, the `CREATE_RELATIONSHIP` event is bound to the type targeted for the subscription.
Consequently, if types A and B have xref:subscriptions/events.adoc#create-non-reciprocal-relationships[non-reciprocal relationships] and a GraphQL operation creates a relationship between them (despite being already previously connected in the database), the `CREATE_RELATIONSHIP` event should only return the subscription to the type A.
===
====

As an example, consider the following type definitions:

Expand Down Expand Up @@ -1007,10 +1007,10 @@ This object should be populated with properties according to the deleted relatio
* Contains the properties of the nodes connected through the relationship, as well as the properties of the newly deleted relationship, if any.

[NOTE]
===
====
Disconnected nodes that may or may not have been deleted in the process are not covered by this subscription.
To subscribe to these nodes' updates, use the `DELETE` subscriptions.
===
====

Subscriptions to `DELETE_RELATIONSHIP` events can be made with the top-level subscription `[type]RelationshipDeleted`, which contains the following fields:

Expand All @@ -1023,10 +1023,10 @@ While any event unrelated to `relationshipFieldName` should be `null`, the ones
Only top-level properties, without relationships, are available and they are the properties that already existed before the `DELETE_RELATIONSHIP` operation took place.

[NOTE]
===
====
Irrespective of the relationship direction in the database, the `DELETE_RELATIONSHIP` event is bound to the type targeted for the subscription.
Consequently, if types A and B have xref:subscriptions/events.adoc#delete-non-reciprocal-relationships[non-reciprocal relationships] and a GraphQL operation deletes a relationship between them (despite being already previously diconnected in the database), the `DELETE_RELATIONSHIP` event should only return the subscription to the type A.
===
====

As an example, consider these type definitions:

Expand Down
6 changes: 3 additions & 3 deletions modules/ROOT/pages/type-definitions/types/scalar.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ query {
----

| `Float`
| Placeholder text to make the table prettier.
| Represents signed double‐precision fractional values.
a|
[source, graphql, indent=0]
----
Expand All @@ -63,7 +63,7 @@ type Product {
----

| `Boolean`
| Placeholder text to make the table prettier.
| Represents `true` or `false`.
a|
[source, graphql, indent=0]
----
Expand All @@ -80,4 +80,4 @@ type Product {
id: ID!
}
----
|===
|===
1 change: 1 addition & 0 deletions modules/ROOT/partials/reusing-content.adoc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
[[include-typescript]]
This paragraph can be used anywhere with the syntax shown in xref:content-types.adoc#_partials[].