graphql added can_update field, activated REST node patch

This commit is contained in:
Bachir Soussi Chiadmi 2024-03-18 18:56:12 +01:00
parent fd50407980
commit 7819ebcf32
3 changed files with 72 additions and 20 deletions

View File

@ -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

View File

@ -5,18 +5,23 @@ interface NodeInterface {
path: String! path: String!
created: String created: String
changed: String changed: String
uuid: String!
bundle: String!
can_update: Boolean
} }
type Concernement implements NodeInterface { type Concernement implements NodeInterface {
id: Int! id: Int!
revision_id: Int!
path: String! path: String!
uuid: String!
bundle: String!
title: String!
author: User
created: String created: String
changed: String changed: String
uuid: String!
bundle: String!
can_update: Boolean
#
revision_id: Int!
title: String!
author: User
lieu: [Taxoterm] lieu: [Taxoterm]
description: String description: String
caillou: String caillou: String
@ -38,12 +43,14 @@ type Entiteintegre {
type Entite implements NodeInterface { type Entite implements NodeInterface {
id: Int! id: Int!
path: String! path: String!
uuid: String!
bundle: String!
title: String!
author: User
created: String created: String
changed: String changed: String
uuid: String!
bundle: String!
can_update: Boolean
#
title: String!
author: User
action: String action: String
menacemaintien: String menacemaintien: String
superposition: [Entite] superposition: [Entite]
@ -68,9 +75,13 @@ type Source {
type Besoin implements NodeInterface { type Besoin implements NodeInterface {
id: Int! id: Int!
path: String! path: String!
author: String
created: String created: String
changed: String changed: String
uuid: String!
bundle: String!
can_update: Boolean
#
author: String
description: String! description: String!
index: Int index: Int
concernement: Concernement concernement: Concernement
@ -80,9 +91,13 @@ type Besoin implements NodeInterface {
type Reponse implements NodeInterface { type Reponse implements NodeInterface {
id: Int! id: Int!
path: String! path: String!
author: String
created: String created: String
changed: String changed: String
uuid: String!
bundle: String!
can_update: Boolean
#
author: String
besoin: Besoin besoin: Besoin
qui: String qui: String
quoi: String quoi: String
@ -93,12 +108,14 @@ type Reponse implements NodeInterface {
type Doleance implements NodeInterface { type Doleance implements NodeInterface {
id: Int! id: Int!
path: String! path: String!
uuid: String!
bundle: String!
title: String!
author: String
created: String created: String
changed: String changed: String
uuid: String!
bundle: String!
can_update: Boolean
#
title: String!
author: String
#1 #1
date_leprobleme: Date date_leprobleme: Date
leprobleme: String leprobleme: String
@ -157,13 +174,15 @@ type ReceptionsApplications {
type Static implements NodeInterface { type Static implements NodeInterface {
id: Int! id: Int!
uuid: String!
bundle: String!
title: String!
path: String! path: String!
author: String
created: String created: String
changed: String changed: String
uuid: String!
bundle: String!
can_update: Boolean
#
title: String!
author: String
promoted: Boolean promoted: Boolean
texte: String texte: String
} }

View File

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