tjanczuk / edge

Run .NET and Node.js code in-process on Windows, MacOS, and Linux
http://tjanczuk.github.io/edge
Other
5.42k stars 640 forks source link

Using edge from a graphql server #319

Open sammosampson opened 9 years ago

sammosampson commented 9 years ago

Hi I am trying to call an edge function from inside a running graphql server (running on express) but it cannot find my assembly:

var edge = require('edge');

var clrMethod = edge.func({ assemblyFile: 'SystemDot.MessageRouteInspector.Server.dll', typeName: 'SystemDot.MessageRouteInspector.Server.RequestDispatcher', methodName: 'DispatchRequest' });

module.exports = function(request, onResponse) { clrMethod(null, function (error, result) { if (error) throw error; onResponse(result); }); }

Running my graphql query returns:

{ "data": { "app": { "routes": null } }, "errors": [ { "message": "Could not load file or assembly 'file:///E:\Work\MessageRouteInspector\SystemDot.MessageRouteInspector.Server.dll' or one of its dependencies. The system cannot find the file specified.", "locations": [ { "line": 1, "column": 6 } ] } ] }

I am using the realy starter kit () Please help. https://github.com/relayjs/relay-starter-kit.

Here is the script that runs my server:

import express from 'express'; import graphQLHTTP from 'express-graphql'; import path from 'path'; import webpack from 'webpack'; import WebpackDevServer from 'webpack-dev-server'; import {Schema} from './data/schema';

const APP_PORT = 3001; const GRAPHQL_PORT = 8081;

// Expose a GraphQL endpoint var graphQLServer = express(); graphQLServer.use('/', graphQLHTTP({schema: Schema, pretty: true})); graphQLServer.listen(GRAPHQL_PORT, () => console.log( GraphQL Server is now running on http://localhost:${GRAPHQL_PORT} ));

// Serve the Relay app var compiler = webpack({ entry: path.resolve(__dirname, 'js', 'app.js'), module: { loaders: [ { test: /.js$/, loader: 'babel', query: {stage: 0, plugins: ['./build/babelRelayPlugin']} } ] }, output: {filename: 'app.js', path: '/'} }); var app = new WebpackDevServer(compiler, { contentBase: '/public/', proxy: {'/graphql': http://localhost:${GRAPHQL_PORT}}, publicPath: '/js/', stats: {colors: true} }); // Serve static resources app.use('/', express.static('public')); app.use('/node_modules/react', express.static('node_modules/react')); app.use('/node_modules/react-relay', express.static('node_modules/react-relay')); app.listen(APP_PORT, () => { console.log(App is now running on http://localhost:${APP_PORT}); });

b25 commented 8 years ago

try to give a full path to < SystemDot.MessageRouteInspector.Server.dll > also include all references for example

context.executeCSharp = edge.func({ source: path.join(__dirname, 'mycustom bridge.cs'), references: [ 'System.Data.dll', 'System.Core.dll', 'Microsoft.CSharp.dll', 'System.Configuration.dll' ] });

sammosampson commented 8 years ago

Managed to sort it using the inline #r style for dependencies. Can you also specify a full path using the #r way?