# Query interface

**URL:** <https://discuss.dgraph.io/t/query-interface/10120>\
**Category:** GraphQL\
**Tags:** kind:question\
**Created:** [September 9, 2020, 2:54am UTC](https://discuss.dgraph.io/t/query-interface/10120 "2020-09-09T02:54:40Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![forstmeier](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/forstmeier/32/2611_2.png) [@forstmeier](https://discuss.dgraph.io/u/forstmeier)\
**Post date:** [September 9, 2020, 2:54am UTC](https://discuss.dgraph.io/t/query-interface/10120/1 "2020-09-09T02:54:40Z")

</div>

Hi!

I’ve defined an interface (`Org`) and implemented it (`StorageOrg` and `LabOrg`); all three of these types have Dgraph-generated queries but I’m unable to get any data back when using the “interface” query. Is there a limitation behind this? The functionality I was expecting was that querying using the “interface” query with an empty filter (`{}`) would return an unfiltered list of all of the implementations of the `Org` interface. Was this an incorrect assumption?

Best,  
John

---

<div class="post-metadata">

**Author:** ![rajas](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/rajas/32/4393_2.png) [@rajas](https://discuss.dgraph.io/u/rajas)\
**Post date:** [September 9, 2020, 6:28am UTC](https://discuss.dgraph.io/t/query-interface/10120/2 "2020-09-09T06:28:15Z")

</div>

Hi @forstmeier,

Can you provide more information on how you were using the “interface” query ?  
Interfaces in Graphql are useful when you want to return an object or set of objects, but those might be of several different types. By creating an `Org` interface and implementing it in `StorageOrg` and `LabOrg`, three graphql queries will be generated, `queryOrg`, `queryStorageOrg`, `queryLabOrg`.

In case you use the `queryOrg` query as follows,

```auto
query{
    queryOrg{
        id
        ... // Any other predicates present in Org
    }
}

```

you should be able to get a list of all nodes which have type `LabOrg` or `StorageOrg` or any of the types which impelement interface `Org` .

---

<div class="post-metadata">

**Author:** ![forstmeier](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/forstmeier/32/2611_2.png) [@forstmeier](https://discuss.dgraph.io/u/forstmeier)\
**Post date:** [September 9, 2020, 12:29pm UTC](https://discuss.dgraph.io/t/query-interface/10120/3 "2020-09-09T12:29:33Z")

</div>

Hi @rajas!

I was running this query:

```auto
{
	"query": "query QueryOrgs { queryOrg(filter: {}) { id, name, createdOn, updatedOn } }"
}

```

Running the query you provided also didn’t return any data.

Here’s a snippet of my schema:

```auto
interface Org {
	id: ID!
	name: String! @search(by: [hash])
	users: [User] @hasInverse(field: org)
	createdOn: DateTime!
	updatedOn: DateTime!
}

type LabOrg implements Org & Location @auth( ... ) {
	owner: OwnerOrg!
	specimens: [Specimen] @hasInverse(field: lab)
	plans: [Plan] @hasInverse(field: labs)
}

type StorageOrg implements Org & Location @auth( ... ) {
	owner: OwnerOrg!
	specimens: [Specimen] @hasInverse(field: storage)
	plans: [Plan] @hasInverse(field: storages)
}

```

The response that comes back is successful (200 status) and the body looks fine there’s just an empty array for `{ "data": { "queryOrg": [] } }`.

---

<div class="post-metadata">

**Author:** ![rajas](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/rajas/32/4393_2.png) [@rajas](https://discuss.dgraph.io/u/rajas)\
**Post date:** [September 9, 2020, 1:28pm UTC](https://discuss.dgraph.io/t/query-interface/10120/4 "2020-09-09T13:28:55Z")

</div>

Hi @forstmeier,

I have defined similar interfaces and types and I am able to get a list of all nodes with type `LabOrg` or `StorageOrg` in the output on querying with an empty filter.  
I see that you are using `@auth` directive along with types. I suspect that the reason for Graphql returning an empty list is due to the querying user not satisfying the auth rule.

For more details regarding the `@auth` directive: [https://dgraph.io/docs/graphql/authorization/directive/](https://dgraph.io/docs/graphql/authorization/directive/)

---

<div class="post-metadata">

**Author:** ![forstmeier](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/forstmeier/32/2611_2.png) [@forstmeier](https://discuss.dgraph.io/u/forstmeier)\
**Post date:** [September 9, 2020, 3:07pm UTC](https://discuss.dgraph.io/t/query-interface/10120/5 "2020-09-09T15:07:46Z")

</div>

Hey @rajas,

That was my assumption too but if I ran the queries on both the implementations, I was getting results with the same user I was using to query on the interface. The interface itself does _not_ have an `@auth` directive since I was under the impression that there was not yet support for that. I’ll play around with the `@auth` definitions on all of the types/interfaces involved to see if maybe I’m missing something?

Best,  
John

---

<div class="post-metadata">

**Author:** ![pawan](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/pawan/32/1946_2.png) [@pawan](https://discuss.dgraph.io/u/pawan)\
**Post date:** [September 9, 2020, 3:16pm UTC](https://discuss.dgraph.io/t/query-interface/10120/6 "2020-09-09T15:16:29Z")

</div>

Hi @forstmeier

Could you please share the schema and a reproducible example with some mutations and queries that you are running?

---

<div class="post-metadata">

**Author:** ![forstmeier](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/forstmeier/32/2611_2.png) [@forstmeier](https://discuss.dgraph.io/u/forstmeier)\
**Post date:** [September 9, 2020, 4:33pm UTC](https://discuss.dgraph.io/t/query-interface/10120/7 "2020-09-09T16:33:55Z")

</div>

Hey @pawan, here’s some of the resources you requested.

[Current schema](https://github.com/forstmeier/backend/blob/reduce-footprint/database/schema.graphql) - this includes all of the `@auth` stuff I’ve included

Body of the first mutation I send (because I used the `OwnerOrg` ID as my multitenancy barrier):

```auto
{
	"query": "mutation AddOwnerOrgs($input: [AddOwnerOrgInput!]!) { addOwnerOrg(input: $input) { ownerOrg { id } } }",
	"variables": {
		"input": [
			{
				"street": "street1",
				"city": "city1",
				"county": "count1",
				"state": "state1",
				"country": "usa",
				"zip": 11111,
				"name": "first owner org",
				"createdOn": "2006-01-02T15:04:05",
				"updatedOn": "2006-01-02T15:04:05"
			}
		]
	}
}

```

Body of the second mutation sent (this one includes the references to the ID generated by the mutation above:

```auto
{
	"query": "mutation AddStorageOrg($input: [AddStorageOrgInput!]!) { addStorageOrg(input: $input) { storageOrg { name } } }",
	"variables": {
		"input": [
			{
				"street": "street2",
				"city": "city2",
				"county": "county2",
				"state": "state2",
				"country": "usa",
				"zip": 22222,
				"name": "new storage org",
				"createdOn": "2020-01-02T15:04:05",
				"updatedOn": "2020-01-02T15:04:05",
				"owner": {
					"id": "ID_FROM_ABOVE"
				}
			}
		]
	}
}

```

The “interface” query I run (as per the recommendation from @rajas):

```auto
{
	"query": "query { queryOrg { id } } "
}

```

The result here is a 200 status response but no data. I’m able to use the generated `queryStorageOrg` with an empty filter and that pulls back the `StorageOrg` type that was added with the second mutation (as expected).

---

<div class="post-metadata">

**Author:** ![forstmeier](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/forstmeier/32/2611_2.png) [@forstmeier](https://discuss.dgraph.io/u/forstmeier)\
**Post date:** [September 13, 2020, 2:09am UTC](https://discuss.dgraph.io/t/query-interface/10120/8 "2020-09-13T02:09:07Z")

</div>

@pawan and @rajas, I’m continuing to experience this issue. I’ve also tested it out on a separate interface query that my schema generates (`querySpecimen`, also available in the link to the schema I posted in the prior message) but I can’t get it to return any data. I’m getting a 200 status back but `"data": { "querySpecimen": [] }` is the payload.

Basically, what seems to be happening is that querying on the interface types using the generated query is failing. I don’t have `@auth` defined on those interfaces because last I heard it was not supported yet - maybe that’s changed or is the core of my issue?

**EDIT** : I’m also just encountering errors in general now with queries that _sort_ of work but the `@auth` definition I provided does _not_ seem to actually be filtering properly - e.g. for `queryOwnerOrg` _all_ `OwnerOrg` types are being returned, not just the ones that receive a request with a JWT containing a custom claim of `orgID` matching their own `ID` field. I feel like I’ve missed something on how the auth definitions should be working…

---

<div class="post-metadata">

**Author:** ![rajas](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/rajas/32/4393_2.png) [@rajas](https://discuss.dgraph.io/u/rajas)\
**Post date:** [September 14, 2020, 12:26pm UTC](https://discuss.dgraph.io/t/query-interface/10120/11 "2020-09-14T12:26:34Z")

</div>

Hi @forstmeier,

Thanks for sharing more details about the schema. I was able to reproduce the issue you are facing about interface query returning an empty list.

Dgraph currently does not support @auth for interfaces and hence, an empty list is returned. There is an RFC for supporting @auth on interfaces and work would be carried out in next 2-4 weeks. You may find more details [here](http://discuss.hypermode.com/t/auth-for-interfaces/9699)

> [@forstmeier](#):
>
> **EDIT** : I’m also just encountering errors in general now with queries that _sort_ of work but the `@auth` definition I provided does _not_ seem to actually be filtering properly - e.g. for `queryOwnerOrg` _all_ `OwnerOrg` types are being returned, not just the ones that receive a request with a JWT containing a custom claim of `orgID` matching their own `ID` field. I feel like I’ve missed something on how the auth definitions should be working…

Were you facing this issue before. Can you share more details about the schema or examples in which you are facing these issues ?

---

<div class="post-metadata">

**Author:** ![forstmeier](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/forstmeier/32/2611_2.png) [@forstmeier](https://discuss.dgraph.io/u/forstmeier)\
**Post date:** [September 14, 2020, 12:31pm UTC](https://discuss.dgraph.io/t/query-interface/10120/12 "2020-09-14T12:31:58Z")

</div>

@rajas okay, thanks! Perfect info on the coming support (although the link is broken it should be `9699` I believe in the path).

I hadn’t run into this issue directly since I hadn’t actually been testing/integrating the schema on those Types at that point.

I’m marking your comment as the solution so that anyone else who runs into this issue in the next 2-4 weeks can reference the same resources.

---

<div class="post-metadata">

**Author:** ![forstmeier](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/forstmeier/32/2611_2.png) [@forstmeier](https://discuss.dgraph.io/u/forstmeier)\
**Post date:** [September 28, 2020, 4:18pm UTC](https://discuss.dgraph.io/t/query-interface/10120/13 "2020-09-28T16:18:32Z")

</div>

Hi @rajas, I just swung back through to that discussion link you mentioned in your last response and haven’t seen any movement on it and I skimmed through the most recent changelogs - any word on if this is under development?

---

<div class="post-metadata">

**Author:** ![rajas](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/rajas/32/4393_2.png) [@rajas](https://discuss.dgraph.io/u/rajas)\
**Post date:** [September 29, 2020, 4:37pm UTC](https://discuss.dgraph.io/t/query-interface/10120/14 "2020-09-29T16:37:36Z")

</div>

Thanks for checking by. As you can see, the RFC received a few comments delaying its implementation. The issue is high on our priority list and should definitely be there in 20.11 version.

Tagging @minhaj to share any more updates.

---

<div class="post-metadata">

**Author:** ![minhaj](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/minhaj/32/3468_2.png) [@minhaj](https://discuss.dgraph.io/u/minhaj)\
**Post date:** [September 29, 2020, 6:05pm UTC](https://discuss.dgraph.io/t/query-interface/10120/15 "2020-09-29T18:05:46Z")

</div>

We will work on the RFC this week and it should be implemented in next couple of weeks hopefully. It is high priority for us also.

---

<div class="post-metadata">

**Author:** ![forstmeier](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/forstmeier/32/2611_2.png) [@forstmeier](https://discuss.dgraph.io/u/forstmeier)\
**Post date:** [October 14, 2020, 1:49am UTC](https://discuss.dgraph.io/t/query-interface/10120/17 "2020-10-14T01:49:22Z")

</div>

Hi @minhaj just touching base on this - I skimmed the most recent changelogs but didn’t see anything and wanted to see where things stood.

---

<div class="post-metadata">

**Author:** ![minhaj](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/minhaj/32/3468_2.png) [@minhaj](https://discuss.dgraph.io/u/minhaj)\
**Post date:** [October 14, 2020, 4:47am UTC](https://discuss.dgraph.io/t/query-interface/10120/18 "2020-10-14T04:47:56Z")

</div>

Hi @forstmeier, We will be taking up this from the next week hopefully.

---

<div class="post-metadata">

**Author:** ![rajas](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/rajas/32/4393_2.png) [@rajas](https://discuss.dgraph.io/u/rajas)\
**Post date:** [October 30, 2020, 5:48am UTC](https://discuss.dgraph.io/t/query-interface/10120/19 "2020-10-30T05:48:05Z")

</div>

Hi @forstmeier,

The PR for enabling auth on querying interfaces has been merged into master. This feature should be there in 20.11 .  
Reference : [feat(GraphQL): Allow Query with Auth rules on Interfaces by minhaj-shakeel · Pull Request #6776 · dgraph-io/dgraph · GitHub](https://github.com/dgraph-io/dgraph/pull/6776)
