How to delete a schema type using json

Is it possible to delete a schema type and/or predicate using json and running a mutation? The only thing I have been able to find so far is using a mutation to delete a node and data but not a type or predicate.

The documentation I found here : [Delete Mutations - GraphQL] : demonstrates using a delete mutation to delete a node of a specific type. I would think that there has to be since the UI can do it.

Any assistance is greatly appreciated.

Hi @reasley,

Assuming you’re using a GraphQL schema and not DQL, the only way to remove specific types/fields from the schema is to upload a new schema entirely minus those types/fields.
The reason we cannot edit a GraphQL schema to remove or add specific types alone is because the entire schema is stored as a ‘String’ inside a DQL predicate called <dgraph.graphql.schema> as

<some-uid> <dgraph.graphql.schema> "<stringified-graphql-schema>".

You can even retrieve the entire schema using pure DQL using:

{ 
  q(func: has(dgraph.graphql.schema)) {
    uid
    dgraph.graphql.schema
  }
}

So it is an architectural constraint that we cannot update specific components in a GraphQL schema as of today, but we’re aware of these limitations and do have plans wrt this. Hopefully in future versions it should be possible to do so, but as of today the only way is to upload a new GraphQL schema altogether.

HTH!

Thanks for the help. I thought that was what I was supposed to do but at the time of the post it wasn’t doing that. Just tried again and it seemed to work. Guess it was just Operator Error. Thank you for the explanation, I appreciate it.

1 Like

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