Search code examples
ibm-cloudgraph-databasesibm-graph

In IBM Graph, How can delete my entire graph and start over without deleting my instance


I'm using IBM Graph and I'd like to be able to delete my entire graph to reload the data. I'm told that I need to delete my service instance and create a new one. Is there any other way to do this without having to keep creating new instances?


Solution

  • Yes absolutely!

    The best way to do this is to use the /_graphs endpoint which allows you to manage multiple graphs under the same instance.

    Here's how you'd delete grph g2

    Delete a graph : DELETE /_graphs/:_gid

    $curl  -u  username:password  -X DELETE "http://.../<serviceid>/g2"
    

    But you can also do other neat stuff as well such as

    Adding a new graph POST /_graphs

    $curl  -u  username:password  -X POST "http://.../<serviceid>/_graphs"
    
    $ {"graph_id":"105512b6-db95-412c-aa3c-6b8fa6c3a844","dbUrl":"http://.../<serviceid>/105512b6-db95-412c-aa3c-6b8fa6c3a844"}
    

    Add a graph with a specific name POST /_graphs/:_gid

    $curl  -u  username:password  -X POST "http://.../<serviceid>/_graphs/g2"
    
    $ {"graph_id":"g2","dbUrl":"http://127.0.0.1:3001/service123/g2"}
    

    Get List of Graphs GET /_graphs

    $curl  -u  username:password  -X GET "http://.../<serviceid>/_graphs"
    
    $ {"graph_ids":["g2","105512b6-db95-412c-aa3c-6b8fa6c3a844","203312b6-de95-412c-ab3c-6b8fe6cda844"]}