Is it possible to define index on type level?

How can I add an @reverse index for Service type, but not to Service2?

type Service {
    deps
}

type Service2 {
    deps
}

deps: [uid] @reverse @count .

Can I define Interfaces in schema like in GraphQL?

You can use two different predicates in those services:

type Service {
    Service.deps
}

type Service2 {
    Service2.deps
}

Service.deps: [uid] @reverse @count .
Service2.deps: [uid] @count .

It is not possible to share the same predicate across types and have differing indexes.

No, DQL schema doesn’t have the concept of interfaces. They exist only in GraphQL schema.

1 Like

Thank you!

BTW can I inherit other types when defining some type in schema?

No, with DQL schema, you can’t.

Interfaces and inheritance is only possible in GraphQL schema.

Why not use GraphQL for what you are are trying to do?
Docs: https://dgraph.io/docs/graphql/overview/

1 Like

I got confused that there are DQL schema and GraphQL schema.

Are there benefits in defining DQL schema if GraphQL schema is more powerful?

They both have their strong points. But FYI, a GraphQL schema will generate a matching DQL schema. It all depends on your use case. If you are going to use the GraphQL endpoint, then you have to use the GraphQL schema. Now you can even then, modify the DQL schema to add things such as facets or linking different predicates together and using the @dgraph directive in the GraphQL schema. I really recommend you following the link I posted here above to get an overall foundation to how what and why all of this.

3 Likes

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.