Can't query on interfaces

referring to the previous bug described here

Using Dgraph 20.11.rc3 the behavior is still wrong

Conditions:
Type A implements interface B and C

Action:

query {
   getB {
   ... on C {
         some C Fields
      }
   }
}

Expected behavior:
The fragment on C should resolve for A because it implements the 2 interfaces

Actual Behaviour:
Graphql do not resolve any entity for the getB query, returning null

Is seems that while the fragment resolution on interface works, now the query do not correctly resolve on interface, making the whole interface architecture inutilizable.

Hi @Luscha, can you please specify schema and query for which you are getting error. I am not able to get what you mean by Graphql do not resolve any entity for thegetB query, returning null

I am trying below and it’s working for me.

Schema:

interface  Meta {
  id: String! @id @search(by: [hash])
}

interface Generic {
  names: [String!]!
}

type Movie implements Meta & Generic {
  description: String!
}

mutation:

 mutation{
    addMovie(input:[{id:"abc",names:["xyz"],description:"dgraph"}]){
      movie{
            id
            names
            description
      }
    }
}

query :

query {
   getMeta(id:"abc") {
       id
       ... on Generic {
           names
       }
   }
}

response:

{
    "data": {
        "getMeta": {
            "id": "abc",
            "names": [
                "xyz"
            ]
        }
    }
}

@JatinDevDG

using DQL mutation the resolution breaks, tested today on v20.11-rc5

DQL Mutation

{
  set {
    <0x01> <Generic.names> "xyz" .
    <0x01> <Meta.id> "abc" .
    <0x01> <Movie.description> "dgraph" .
  }
}

DQL Query;

{
  res(func:has(Meta.id)) {
    Meta.id
    Generic.names
    Movie.description
  }
}

DQL Response:

{
  "data": {
    "res": [
      {
        "Meta.id": "abc",
        "Generic.names": [
          "xyz"
        ],
        "Movie.description": "dgraph"
      }
    ]
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 46300,
      "processing_ns": 317000,
      "encoding_ns": 40400,
      "total_ns": 446700
    },
    "txn": {
      "start_ts": 24
    },
    "metrics": {
      "num_uids": {
        "Generic.names": 1,
        "Meta.id": 1,
        "Movie.description": 1,
        "_total": 3
      }
    }
  }
}

GraphQL query:

query {
   getMeta(id:"abc") {
       id
       ... on Generic {
           names
       }
   }
}

GraphQL Rsponse:

{
  "data": {
    "getMeta": null
  },
  "extensions": {
    "tracing": {
      "version": 1,
      "startTime": "2020-12-15T15:59:49.9269379Z",
      "endTime": "2020-12-15T15:59:49.9286073Z",
      "duration": 1669500,
      "execution": {
        "resolvers": [
          {
            "path": [
              "getMeta"
            ],
            "parentType": "Query",
            "fieldName": "getMeta",
            "returnType": "Meta",
            "startOffset": 113600,
            "duration": 1547400,
            "dgraph": [
              {
                "label": "query",
                "startOffset": 186800,
                "duration": 1461600
              }
            ]
          }
        ]
      }
    }
  }
}

Really hope it is a bug and not a design decision :frowning:

you need to mention dgraph.type of the object in RDF to get response in graphql query. In case of interfaces we need to mention all the possible types that the resulting object can be of.
In your RDF you need to add these lines and then graphql query will work.


<0x1> <dgraph.type> "Meta" .
<0x1> <dgraph.type> "Generic" .
<0x1> <dgraph.type> "Movie" .
1 Like

I see, now that you said that it makes totally sense.
Thak you