GraphQL fragments do not support namespaces

Hello,
On Stardog 5.3.2, I’m trying to write a graphql query involving fragments, and finding that namespace prefixes aren’t handled correctly when interpreting the subtype name. For example, here’s a graphql query and associated sparql query (via explain command) (assume starwars is a stored namespace prefix):

{
  starwars_Character {
        starwars_name
        ... on starwars_Droid {
              starwars_primaryFunction
        }
  }
}

SELECT *
FROM <tag:stardog:api:context:all>
{
    ?0 rdf:type starwars:Character .
    ?0 starwars:name ?1 .
    OPTIONAL {
        ?0 rdf:type :starwars_Droid .
        BIND(true AS ?2)
        OPTIONAL {
            BIND(true AS ?3)
            ?0 starwars:primaryFunction ?4 .
        }
    }
    FILTER(!bound(?2) || bound(?3))
}

Observe the erroneous pattern:
?0 rdf:type :starwars_Droid .

Any suggestions? Thanks!
Eron

Thanks for the report. This indeed is a bug and I created the issue 5790 in our internal issue tracker.

I think right now the only workaround is to declare the starwars namespace as the default namespace for the query (using @prefix(_: "...")) so fragments use the default namespace (as long as all your fragments use the same namespace).

Best,
Evren

1 Like