This project is not covered by Drupal’s security advisory policy.
Provides an integration between GraphQL and Flag modules.
Dependencies
- Flag 8.4.x
- GraphQL 8.3.x
Features
Queries
Per content entity Flaggings
Returns a list of Flaggings for an entity and a Flag.
Example use case: list of users that 'liked' a node.
query { nodeById(id:"1") { entityId entityFlagging(flag_id:"like") { entityFlaggings { flagId flagging { entityOwner { name mail } } } } } }
Per content entity Flagging counts
Returns a list of Flagging counts by entity type, for each Flag.
Example use case: number of 'likes' and 'views' for nodes.
fragment flaggingCounts on EntityFlaggingCountList { count: entityFlaggingCounts { flagId amount } } query { nodeQuery { entities { entityId entityFlaggingCount { ... flaggingCounts } } } }
With optional filtering by Flags
query { nodeQuery { entities { entityId entityFlaggingCount(flag_id:["like", "view"]) { ... flaggingCounts } } } }
Personal Flaggings
Get flagged entities for a user. Applies to the Flags that have the 'Personal' scope.
Example use case: get the 'likes' on entities for a user,
so states for these elements can then be used to flag/unflag on a decoupled client
with mutations queries (see below).
Example, get the user 1 Flaggings for the "like" Flag.
query { userById(id: "1") { ...on User { entityId userFlagging(flag_id: ["like"]) { userFlaggings { flagId entityId entityType } } } } }
Mutations
There is a generic mutation, with an 'operation' parameter:
'flag' and 'unflag' operations are supported.
Mutation queries are returning errors or the Flagging entity id.
mutation($input: FlaggingInput!) { flag(input: $input) { entity { entityId entityType } errors violations { message } } }
Flag
Example of mutation input for flagging an entity with the 'like' Flag.
The user id is optional, it defaults to the current user id.
{ "input": { "operation": "flag", "flag_id": "like", "entity_type": "node", "entity_id": 1, "user_id": 1 } }
Unflag
Example of mutation input for unflagging an entity with the 'like' Flag.
The user id is optional, it defaults to the current user id.
{ "input": { "operation": "unflag", "flag_id": "like", "entity_type": "node", "entity_id": 1, "user_id": 1 } }
Project information
Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed.Maintenance fixes only
Considered feature-complete by its maintainers.- Project categories: Decoupled, Integrations
- Ecosystem: Flag, GraphQL
8 sites report using this module
- Created by colorfield on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.





