소스 검색

graphql added can_update field, activated REST node patch

bach 2 달 전
부모
커밋
7819ebcf32

+ 19 - 0
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

+ 31 - 12
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!
+  created: String
+  changed: String
   uuid: String!
   bundle: String!
+  can_update: Boolean
+  #
+  revision_id: Int!
   title: String!
   author: User
-  created: String
-  changed: String
   lieu: [Taxoterm]
   description: String
   caillou: String
@@ -38,12 +43,14 @@ type Entiteintegre {
 type Entite implements NodeInterface {
   id: Int!
   path: String!
+  created: String
+  changed: String
   uuid: String!
   bundle: String!
+  can_update: Boolean
+  #
   title: String!
   author: User
-  created: String
-  changed: String
   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!
+  created: String
+  changed: String
   uuid: String!
   bundle: String!
+  can_update: Boolean
+  #
   title: String!
   author: String
-  created: String
-  changed: String
   #1
   date_leprobleme: Date
   leprobleme: String
@@ -157,13 +174,15 @@ type ReceptionsApplications {
 
 type Static implements NodeInterface {
   id: Int!
+  path: String!
+  created: String
+  changed: String
   uuid: String!
   bundle: String!
+  can_update: Boolean
+  #
   title: String!
-  path: String!
   author: String
-  created: String
-  changed: String
   promoted: Boolean
   texte: String
 }

+ 15 - 1
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;
+        })
+      )
+    );
+    
+
   }
 
   //   _____       _   _ _    __        ___       _    __             __