Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 modules/ROOT/pages/introspector.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This tool has full support for generating type definitions, including:
- `@node`
- `label` for mapping where a node label might use a character that's not in the GraphQL supported character set
- `additionalLabels` for nodes that has multiple labels
- Generating a read-only version of the GraphQL type definitions, i.e. generate a `@exclude(operations: [CREATE, DELETE, UPDATE])` directive on all node types.
- Generating a read-only version of the GraphQL type definitions

== Limitations

Expand Down
13 changes: 9 additions & 4 deletions modules/ROOT/pages/ogm/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ Most applications won't just expose a single GraphQL API. There may also be sche

The following directives are excluded from the OGM's schema:

- `@auth`
- `@exclude`
- `@authentication`
- `@authorization`
- `@subscriptionsAuthorization`
- `@private`
- `@readonly`
- `@writeonly`
- `@query`
- `@mutation`
- `@subscription`
- `@filterable`
- `@selectable`
- `@settable`

This is because the OGM is only ever used programmatically, as opposed to an exposed API which needs these security measures.

Expand Down
21 changes: 0 additions & 21 deletions modules/ROOT/pages/reference/directives/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ The `@alias` directive will map a GraphQL schema field to a Neo4j property on a

Reference: xref::reference/directives/database-mapping.adoc#type-definitions-alias[`@alias`]

== `@auth`
label:deprecated[]

The `@auth` directive is used to define complex fine-grained and role-based access control for object types and fields.

== `@coalesce`

The `@coalesce` directive exposes a mechanism for querying against non-existent, `null` values on a node.
Expand Down Expand Up @@ -112,13 +107,6 @@ The `@queryOptions` is to be used on nodes, where applied will inject values int

Reference: xref::reference/directives/default-values.adoc#type-definitions-default-values-queryoptions[`@queryOptions`]

== `@readonly` label:deprecated[]

This directive is deprecated. See the xref:reference/directives/schema-configuration/field-configuration.adoc#_settable[`@settable`] directive.
The `@readonly` directive marks fields as read-only.

Reference: xref::reference/directives/schema-configuration/field-configuration.adoc#_readonly_deprecated[`@readonly`]

== `@relationship`

The `@relationship` directive is used to configure relationships between object types.
Expand Down Expand Up @@ -166,12 +154,3 @@ Reference: xref::reference/directives/autogeneration.adoc#type-definitions-autog
The `@unique` directive indicates that there should be a uniqueness constraint in the database for the fields that it is applied to.

Reference: xref::reference/type-definitions/indexes-and-constraints.adoc#type-definitions-constraints-unique[Unique node property constraints]

== `@writeonly` label:deprecated[]

This directive is deprecated.

Use the xref:reference/directives/schema-configuration/field-configuration.adoc#_selectable[`@selectable`] directive instead.
The `@writeonly` directive marks fields as write-only.

Reference: xref::reference/directives/schema-configuration/field-configuration.adoc#_writeonly_deprecated[`@writeonly`]
Original file line number Diff line number Diff line change
Expand Up @@ -153,88 +153,3 @@ type Movie @subscription(operations: [CREATE]) {
length: Int
}
----

== `@exclude` label:deprecated[]

This directive skips the generation of queries and/or subscriptions and/or particular/all mutations for the specified type.

[NOTE]
====
This directive is deprecated.

Use the xref:reference/directives/schema-configuration/type-configuration.adoc#_query[`@query`], xref:reference/directives/schema-configuration/type-configuration.adoc#_mutation[`@mutation`] and the xref:reference/directives/schema-configuration/type-configuration.adoc#_subscription[`@subscription`] directives instead.
====

=== Definition

[source, graphql, indent=0]
----
enum ExcludeOperation {
CREATE
READ
UPDATE
DELETE
SUBSCRIBE
}

"""Instructs @neo4j/graphql to exclude the specified operations from query, mutation and subscription generation. If used without an argument, no queries, mutations or subscriptions will be generated for this type."""
directive @exclude(
operations: [ExcludeOperation!]! = [CREATE, READ, UPDATE, DELETE, SUBSCRIBE]
) on OBJECT
----

=== Usage

==== Disable Query field generation

[source, graphql, indent=0]
----
type User @exclude(operations: [READ]) {
name: String
}
----

==== Disable single Mutation field generation

[source, graphql, indent=0]
----
type User @exclude(operations: [CREATE]) {
name: String
}
----

==== Disable multiple Mutation field generation

[source, graphql, indent=0]
----
type User @exclude(operations: [CREATE, DELETE]) {
name: String
}
----

==== Disable Subscription field generation

[source, graphql, indent=0]
----
type User @exclude(operations: [SUBSCRIBE]) {
name: String
}
----

==== Disable all Query, Mutation, and Subscription field generation

The following two type definitions are equivalent in the sense that no queries, mutations, or subscriptions will be generated for either of them:

[source, graphql, indent=0]
----
type User @exclude {
name: String
}
----

[source, graphql, indent=0]
----
type User @exclude(operations: [CREATE, READ, UPDATE, DELETE, SUBSCRIBE]) {
name: String
}
----
42 changes: 0 additions & 42 deletions modules/ROOT/pages/reference/type-definitions/interfaces.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,48 +71,6 @@ type Actor {
}
----

==== Overriding

In addition to inheritance, directives can be overridden on a per-implementation basis. Say you had an interface defining some `Content`, with some basic authorization rules:

[source, graphql, indent=0]
----
interface Content
@auth(rules: [{ operations: [CREATE, UPDATE, DELETE], allow: { author: { username: "$jwt.sub" } } }]) {
title: String!
author: [Author!]! @relationship(type: "HAS_CONTENT", direction: IN)
}

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

You might implement this once for public content and once for private content which has additional rules in place:

[source, graphql, indent=0]
----
type PublicContent implements Content {
title: String!
author: [Author!]!
}

type PrivateContent implements Content
@auth(rules: [{ operations: [CREATE, READ, UPDATE, DELETE], allow: { author: { username: "$jwt.sub" } } }]) {
title: String!
author: [Author!]!
}
----

The `PublicContent` type will inherit the auth rules from the `Content` interface, whilst the `PrivateContent` type will use the auth rules specified there.

In summary, there are three choices for the application of directives when using interfaces:

- Directives specified on the interface and inherited by all implementing types when the directives for every type are the same.
- Directives specified on the interface and overridden by certain implementing types when directives are broadly the same with a few discrepancies.
- Directives specified on implementing types alone when there is very little commonality between types, or certain types need a directive and others don't.

[[type-definitions-interfaced-types-querying]]
== Querying an interface

Expand Down