SPARQL API hooks

Last updated on
30 April 2025

The SPARQL API exposes the following Drupal hooks that third-party extension modules can implement to provide extended functionality:

hook_sparql()

Allows modules to modify SPARQL queries before they are executed. This could be said to be the RDF equivalent of db_rewrite_sql().

Example of usage

/**
 * Implementation of hook_sparql().
 */
function mymodule_sparql($op, &$query) {
  switch ($op) {
    case 'ask':
      // An ASK query is being executed
      break;
    case 'select':
      // A SELECT query is being executed
      break;
    case 'construct':
      // A CONSTRUCT query is being executed
      break;
    case 'describe':
      // A DESCRIBE query is being executed
      break;
  }
}

Help improve this page

Page status: Not set

You can: