def query(graph, selection, patterns, optionalPatterns=[], initialBindings = {},
          dSCompliance=False, loadContexts=False):
    result = queryObject(graph, patterns, optionalPatterns,
                         initialBindings, dSCompliance, loadContexts)
    if result == None:

        # generate some proper output for the exception :-)
        msg = "Errors in the patterns, no valid query object generated; "
        if isinstance(patterns, GraphPattern):
            msg += ("pattern:\n%s" % patterns)
        else :
            msg += ("pattern:\n%s\netc..." % patterns[0])

        raise SPARQLError(msg)

    return result.select(selection)
A shorthand for the creation of a :class:`~rdfextras.sparql.query.Query` instance, returning
dataset/ETHPy150Open RDFLib/rdfextras/rdfextras/sparql/query.py/query