GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — cppgraphqlgen/samples/proxy at main · microsoft/cppgraphqlgen

Expand file tree

/

proxy

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

proxy

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
query
query
 
 
schema
schema
 
 
CMakeLists.txt
CMakeLists.txt
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
client.cpp
client.cpp
 
 
server.cpp
server.cpp
 
 

README.md

Outline

HTTP Proxy Sample

Dependencies

This sample requires the Boost.Beast header-only library. If you are using vcpkg, it can install that component for you on-demand. Otherwise, you may need to install it separately if you have a selective installation of Boost.

Server

The server executable listens for HTTP connections on http://127.0.0.1:8080/ (port 8080 of localhost). It is expecting POST requests with a JSON payload in the request body that looks like this:

{
	"query": "GraphQL query document goes here",
	"operationName": "(optional) GraphQL operation name goes here",
	"variables": "(optional) JSON object embedded in a string with GraphQL operation variables"
}

It has a single thread accepting requests, and it uses C++20 coroutines. The GraphQL service which actually resolves the requests is the same Star Wars learning sample in ../learn.

Client

The client executable works like most of the other command line samples, it can take a single argument for the operation name and it will read the GraphQL query document from standard input. It packages the query parameters in variables for a pre-parsed query/query.graphql, and it implements an in-proc GraphQL service with the schema/schema.graphql schema using an asynchronous field resolver. The field resolver packages the parameters into a JSON message and sends it to the server process waiting on http://127.0.0.1:8080/.

When it gets a response, client uses the same pre-parsed query in query/query.graphql to parse the result and return the JSON document in the field returned from the server process.

As long as you start the server process first, the behavior of client should be almost identical to the learn_star_wars executable sample produced by ../learn.

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.