I’m using GraphQL and DQL at the same time. Since the GraphQL schema maps to a DQL schema (docs), I can seamlessly run queries between GraphQL and DQL.
But, I can make changes to my DQL schema directly that would break my GraphQL schema. If a predicate is being used in GraphQL it shouldn’t be modifiable via alter. It should only be changed in the GraphQL schema.
What version of Dgraph are you using?
v20.11.3 / latest
Have you tried reproducing the issue with the latest release?
Yes
Steps to reproduce the issue (command/config used to run Dgraph).
-
Set a GraphQL schema to Dgraph.
type Product { name: String! @search(by: [hash]) }
This creates a Dgraph schema entry for
Product.name: string @index(hash) .
-
Add data and queries in GraphQL, which work as you expect:
mutation Product { addProduct(input: [{name: "Product A"}]) { product { name } } } query GetPerson { queryProduct(filter: {name: {eq: "Product A"}}) { name } }
{ "data": { "queryProduct": [ { "name": "Product A" } ] } ... }
-
Update the DQL schema to change the indexing:
Product.name: string @index(trigram) .
This makes the DQL schema inconsistent with the GraphQL schema.
-
Running the same query in #1 returns an error message:
{ "errors": [ { "message": "Dgraph query failed because Dgraph execution failed because : Attribute Product.name does not have a valid tokenizer." } ], "data": { "queryProduct": [] } }
Expected behaviour and actual result.
I shouldn’t be able to change the DQL schema to cause these GraphQL errors.