package com.reactlibrary;

import android.util.Base64;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import org.tensorflow.Graph;

public class RNTensorflowGraphModule extends ReactContextBaseJavaModule {

    private Graph graph;

    public RNTensorflowGraphModule(ReactApplicationContext reactContext) {
        super(reactContext);
    }

    @Override
    public String getName() {
        return "TensorflowGraph";
    }

    @ReactMethod
    public void init(Graph graph) {
        this.graph = graph;
    }

    @ReactMethod
    public void importGraphDef(String graphDef) {
        this.graph.importGraphDef(Base64.decode(graphDef, Base64.DEFAULT));
    }

    @ReactMethod
    public void importGraphDef(String graphDef, String prefix) {
        this.graph.importGraphDef(Base64.decode(graphDef, Base64.DEFAULT), prefix);
    }

    @ReactMethod
    public void toGraphDef(Promise promise) {
        try {
            promise.resolve(Base64.encodeToString(this.graph.toGraphDef(), Base64.DEFAULT));
        } catch (Exception e) {
            promise.resolve(e);
        }
    }

    @ReactMethod
    public void operation(String name, Promise promise) {
        try {
            promise.resolve(this.graph.operation(name));
        } catch (Exception e) {
            promise.resolve(e);
        }
    }

    @ReactMethod
    public void close() {
        this.graph.close();
    }
}

@@ -384,16 +384,66 @@
 h graph;
+%0A    private ReactApplicationContext reactContext;
 %0A%0A    pu
@@ -540,16 +540,58 @@
 ntext);%0A
+        this.reactContext = reactContext;%0A
     %7D%0A%0A 
@@ -1441,50 +1441,247 @@
     
-promise.resolve(this.graph.operation(name)
+RNTensorflowGraphOperationsModule operationsModule =%0A                    reactContext.getNativeModule(RNTensorflowGraphOperationsModule.class);%0A            operationsModule.init(this.graph.operation(name));%0A            promise.resolve(true
 );%0A 

Fix opration call