rubensworks / GraphQL-LD.js

Linked Data Querying with GraphQL
https://gist.github.com/rubensworks/9d6eccce996317677d71944ed1087ea6
MIT License
103 stars 7 forks source link

@optional at root fails with other nested @optionals #22

Closed pheyvaer closed 4 years ago

pheyvaer commented 4 years ago

Consider the following

const comunicaConfig = {
  sources: [
    'https://raw.githubusercontent.com/RMLio/rmlmapper-java/master/src/main/resources/functions_idlab.ttl',
    'https://raw.githubusercontent.com/RMLio/rmlmapper-java/master/src/main/resources/functions_grel.ttl'
  ],
};

const context = {
    "@context": {
      "fno": "https://w3id.org/function/ontology#",
      "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
      "dcterms": "http://purl.org/dc/terms/",
      "Function": "fno:Function",
      "fnoType": "fnoType",
      "label": { "@id": "http://www.w3.org/2000/01/rdf-schema#label" },
      "type": "rdf:type",
      "expects": "fno:expects",
      "predicate": "fno:predicate",
      "first": "rdf:first",
      "rest": "rdf:rest",
      "description": "dcterms:description",
      "name": "fno:name"
    }
  };
  const client = new Client({ context, queryEngine: new QueryEngineComunica(comunicaConfig) });

  const query = `
  query {
    id @single
    type (_:Function)
    description @single @optional
    expects @single @optional {
      first @single {
        id @single
        label @single
        predicate @single
      }
      rest @single @optional {
        first @single {
          id @single
          label @single
          predicate @single
        }
        rest @single @optional {
          first @single {
            id @single
            label @single
            predicate @single
          }
          rest @single @optional {
            first @single {
              id @single
              label @single
              predicate @single
            }
          }
        }
      }
    }
  }`;

  const { data } = await client.query({ query });

This fails, but no error is given. But it works when I either:

rest @single @optional {
            first @single {
              id @single
              label @single
              predicate @single
            }
          }

GraphQL-LD version = 1.0.1 Node version = 12.16.1

I did not try it with the latest version of Comunica on the master because I did not get that working locally. So the issue might be fixed already there.

rubensworks commented 4 years ago

I did not try it with the latest version of Comunica on the master because I did not get that working locally. So the issue might be fixed already there.

It will most likely be fixed there indeed. I'll put this on-hold until the new version is released.

rubensworks commented 4 years ago

New version has been released: 1.1.0.