diff --git a/src/config/sync/rest.resource.entity.node.yml b/src/config/sync/rest.resource.entity.node.yml new file mode 100644 index 0000000..e083409 --- /dev/null +++ b/src/config/sync/rest.resource.entity.node.yml @@ -0,0 +1,19 @@ +uuid: 2440a352-f464-4f5e-b230-247dd83e6602 +langcode: fr +status: true +dependencies: + module: + - node + - serialization + - user +id: entity.node +plugin_id: 'entity:node' +granularity: resource +configuration: + methods: + - POST + - PATCH + formats: + - json + authentication: + - cookie diff --git a/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls b/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls index f94a6bb..801207e 100644 --- a/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls +++ b/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls @@ -5,18 +5,23 @@ interface NodeInterface { path: String! created: String changed: String + uuid: String! + bundle: String! + can_update: Boolean } type Concernement implements NodeInterface { id: Int! - revision_id: Int! path: String! - uuid: String! - bundle: String! - title: String! - author: User created: String changed: String + uuid: String! + bundle: String! + can_update: Boolean + # + revision_id: Int! + title: String! + author: User lieu: [Taxoterm] description: String caillou: String @@ -38,12 +43,14 @@ type Entiteintegre { type Entite implements NodeInterface { id: Int! path: String! - uuid: String! - bundle: String! - title: String! - author: User created: String changed: String + uuid: String! + bundle: String! + can_update: Boolean + # + title: String! + author: User action: String menacemaintien: String superposition: [Entite] @@ -68,9 +75,13 @@ type Source { type Besoin implements NodeInterface { id: Int! path: String! - author: String created: String changed: String + uuid: String! + bundle: String! + can_update: Boolean + # + author: String description: String! index: Int concernement: Concernement @@ -80,9 +91,13 @@ type Besoin implements NodeInterface { type Reponse implements NodeInterface { id: Int! path: String! - author: String created: String changed: String + uuid: String! + bundle: String! + can_update: Boolean + # + author: String besoin: Besoin qui: String quoi: String @@ -93,12 +108,14 @@ type Reponse implements NodeInterface { type Doleance implements NodeInterface { id: Int! path: String! - uuid: String! - bundle: String! - title: String! - author: String created: String changed: String + uuid: String! + bundle: String! + can_update: Boolean + # + title: String! + author: String #1 date_leprobleme: Date leprobleme: String @@ -157,13 +174,15 @@ type ReceptionsApplications { type Static implements NodeInterface { id: Int! - uuid: String! - bundle: String! - title: String! path: String! - author: String created: String changed: String + uuid: String! + bundle: String! + can_update: Boolean + # + title: String! + author: String promoted: Boolean texte: String } diff --git a/src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php b/src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php index f2492a4..dece1ac 100644 --- a/src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php +++ b/src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php @@ -310,7 +310,21 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase { }) ) ); - + + // editable: Boolean + $registry->addFieldResolver('Concernement', 'can_update', + $builder->compose( + $builder->callback(function(/** @var Drupal\node\Entity\node */ $parent, $arg){ + $t="t"; + // $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id()); + $user = \Drupal::currentUser(); + $can_update = $parent->access('update', $user); + return $can_update; + }) + ) + ); + + } // _____ _ _ _ __ ___ _ __ __