Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Sample Node Native Module (for Electron) which exposes a cppgraphqlgen service as a GraphQL endpoint

License

Notifications You must be signed in to change notification settings

wravery/electron-cppgraphql

Open more actions menu

Repository files navigation

electron-cppgraphql

This is a sample Node Native Module (for Electron) which exposes a cppgraphqlgen service as a GraphQL endpoint. You could change some of the target configuration to work with regular Node as well, but I used this with an Electron app hosting GraphiQL, so that's how it's configured out of the box.

The relevant bits are all in NodeBinding.cpp. I used the vcpkg package manager to install cppgraphqlgen v3.0.0 and all of its dependencies. I used cmake-js to integrate with vcpkg and CMake (instead of the standard GYP-based process), and I used the NAN project to make it somewhat resilient to different versions of Node or Electron.

If you get this working on your own machine, the result should be a file named ./build/Release/electron-cppgraphql.node, and if you're on Windows, CMake should put the DLLs exported from cppgraphqlgen next to it. See the cmake-js README for more information about how to call the native methods.

CMake Configuration

I recommend using the NPM Config support provided by cmake-js to setup any CMake configuration variables you need. For example, I used vcpkg to build and install cppgraphqlgen and all of its dependencies, and vcpkg depends on setting CMAKE_TOOLCHAIN_FILE so it points to <vcpkg root>/scripts/buildsystems/vcpkg.cmake. I used the following command to enable vcpkg integration with all of my cmake-js builds (on Windows):

npm config set cmake_CMAKE_TOOLCHAIN_FILE <vcpkg root>\vcpkg\scripts\buildsystems\vcpkg.cmake

If you're using vcpkg as well, just make sure you replace <vcpkg root> with the absolute path to your vcpkg installation, and replace the \ with / on Unix systems.

About

Sample Node Native Module (for Electron) which exposes a cppgraphqlgen service as a GraphQL endpoint

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  
Morty Proxy This is a proxified and sanitized view of the page, visit original site.