Deleting predicate from schema


(Jeff Hull) #1

Sorry if this question is overly basic…I’m just getting started with GraphQL±.

I would like to delete all of these predicates from my schema:

{  
   "schema":[  
      {  
         "predicate":"name",
         "type":"string"
      },
      {  
         "predicate":"revenue",
         "type":"float"
      },
      {  
         "predicate":"starring",
         "type":"uid"
      },
      {  
         "predicate":"release_date",
         "type":"date",
         "index":true,
         "tokenizer":[  
            "date"
         ]
      },
      {  
         "predicate":"planet",
         "type":"string"
      },
      {  
         "predicate":"director",
         "type":"uid"
      },
      {  
         "predicate":"friend",
         "type":"uid"
      },
      {  
         "predicate":"student",
         "type":"uid"
      },
   ]
}

I tried running a few variations of the “delete” syntax, for example:

mutation {
  delete {
    <planet> * * .
  }
}

But haven’t been successful in deleting the schema predicates. Any help would be appreciated.


Delete a predicate from schema (cont)
(Michael Compton) #2

Do you want to delete everything and start over? To do that, stop dgraph, wait till it’s finished exiting, remove the p and w dirs and restart.


(Jeff Hull) #3

In this case yes that will work :slight_smile: I could see needing to clear out unused schema in the future, but in my case I don’t have much data to lose. Thanks!


(Manish R Jain) #4

It should have been * <planet> *. The predicate is the middle one.


(Jeff Hull) #5

Thanks @mrjn. When I try that though I get this error:

{"code":"Error","message":"'*' only allowed at predicate/object in del mutations"}

Also, if this statement were to work, would it delete all matching quads (data) only, or also the associated schema entry for the predicate? Basically I am looking for the delete operation which would negate this schema definition statement:

mutation {
  schema {
    planet: string .
  }
}

(Manish R Jain) #6

I thought this deletion feature was already there. But, @pawan just pushed this y’day. So, you can expect this in v0.8. Until then, you will have to stop Dgraph, and clear out the underlying directories.


(Pawan Rawal) #7

Hi @tamethecomplex

This was pushed to master a couple of days ago and will go in the next release. You could go get the master build and try this feature out in the meantime.


(system) #8

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