From d68558d1d54d722affcd8bdede5da1b1b0e27b13 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 22 Jan 2024 14:23:36 -0800 Subject: [PATCH 1/5] Create cppgraphqlgen.md --- .../code/language-support/c-c/tools/cppgraphqlgen.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/content/code/language-support/c-c/tools/cppgraphqlgen.md diff --git a/src/content/code/language-support/c-c/tools/cppgraphqlgen.md b/src/content/code/language-support/c-c/tools/cppgraphqlgen.md new file mode 100644 index 0000000000..ff5348ae5c --- /dev/null +++ b/src/content/code/language-support/c-c/tools/cppgraphqlgen.md @@ -0,0 +1,6 @@ +--- +name: cppgraphqlgen +description: A C++20 GraphQL schema service and client generator. +url: https://github.com/microsoft/cppgraphqlgen +github: microsoft/cppgraphqlgen +--- From 9bafa98bdc120260d4a7b6f8934fcf77c1cdba92 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 22 Jan 2024 14:29:19 -0800 Subject: [PATCH 2/5] Add README blurb to help get started --- .../code/language-support/c-c/tools/cppgraphqlgen.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/content/code/language-support/c-c/tools/cppgraphqlgen.md b/src/content/code/language-support/c-c/tools/cppgraphqlgen.md index ff5348ae5c..2f11a7c74b 100644 --- a/src/content/code/language-support/c-c/tools/cppgraphqlgen.md +++ b/src/content/code/language-support/c-c/tools/cppgraphqlgen.md @@ -4,3 +4,12 @@ description: A C++20 GraphQL schema service and client generator. url: https://github.com/microsoft/cppgraphqlgen github: microsoft/cppgraphqlgen --- + +The easiest way to build and install `cppgraphqlgen` is to use [microsoft/vcpkg](https://github.com/microsoft/vcpkg). +See the [Getting Started](https://github.com/microsoft/vcpkg#getting-started) section of the `vcpkg` README +for details. Once you have that configured, run `vcpkg install cppgraphqlgen` (or `cppgraphqlgen:x64-windows`, +`cppgraphqlgen:x86-windows-static`, etc. depending on your platform). That will build and install all of the +dependencies for `cppgraphqlgen`, and then build `cppgraphqlgen` itself without any other setup. The `cppgraphqlgen` +package (and its dependencies) are advertised to the `CMake` `find_package` function through the +`-DCMAKE_TOOLCHAIN_FILE=<...>/scripts/buildsystems/vcpkg.cmake` parameter/variable. There are more details about +this in the `vcpkg` documentation. From 57287572c7ec68e474aadcb92a15f02609046832 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 22 Jan 2024 14:38:16 -0800 Subject: [PATCH 3/5] Move cppgraphqlgen.md out of tools subdir --- .../code/language-support/c-c/{tools => }/cppgraphqlgen.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/content/code/language-support/c-c/{tools => }/cppgraphqlgen.md (100%) diff --git a/src/content/code/language-support/c-c/tools/cppgraphqlgen.md b/src/content/code/language-support/c-c/cppgraphqlgen.md similarity index 100% rename from src/content/code/language-support/c-c/tools/cppgraphqlgen.md rename to src/content/code/language-support/c-c/cppgraphqlgen.md From d0b14d144822bf1d6249f0e964a8021095ba59f4 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 22 Jan 2024 15:09:57 -0800 Subject: [PATCH 4/5] Split cppgraphqlgen into separate client/server entries --- .../c-c/client/cppgraphqlgen-clientgen.md | 34 +++++++++++++++++++ .../language-support/c-c/cppgraphqlgen.md | 15 -------- .../c-c/server/cppgraphqlgen-schemagen.md | 25 ++++++++++++++ 3 files changed, 59 insertions(+), 15 deletions(-) create mode 100644 src/content/code/language-support/c-c/client/cppgraphqlgen-clientgen.md delete mode 100644 src/content/code/language-support/c-c/cppgraphqlgen.md create mode 100644 src/content/code/language-support/c-c/server/cppgraphqlgen-schemagen.md diff --git a/src/content/code/language-support/c-c/client/cppgraphqlgen-clientgen.md b/src/content/code/language-support/c-c/client/cppgraphqlgen-clientgen.md new file mode 100644 index 0000000000..038f2032e0 --- /dev/null +++ b/src/content/code/language-support/c-c/client/cppgraphqlgen-clientgen.md @@ -0,0 +1,34 @@ +--- +name: cppgraphqlgen-clientgen +description: A C++20 GraphQL client request generator and response parser using the schema document. +url: https://github.com/microsoft/cppgraphqlgen +github: microsoft/cppgraphqlgen +--- + +The `clientgen` utility is based on `schemagen` and shares the same external dependencies. The command line arguments +are almost the same, except it takes an extra file for the request document and there is no equivalent to `--stubs`: +``` +Usage: clientgen [options] +Command line options: + --version Print the version number + -? [ --help ] Print the command line options + -v [ --verbose ] Verbose output including generated header names as + well as sources + -s [ --schema ] arg Schema definition file path + -r [ --request ] arg Request document file path + -o [ --operation ] arg Operation name if the request document contains more + than one + -p [ --prefix ] arg Prefix to use for the generated C++ filenames + -n [ --namespace ] arg C++ sub-namespace for the generated types + --source-dir arg Target path for the Client.cpp source file + --header-dir arg Target path for the Client.h header file + --no-introspection Do not expect support for Introspection +``` + +This utility should output one header and one source file for each request document. A request document may contain more +than one operation, in which case it will output definitions for all of them together. You may limit the output to a +single operation from the request document by specifying the `--operation` (or `-o`) argument with the operation name. + +The generated code depends on the `graphqlclient` library for serialization of built-in types. If you link the generated +code, you'll also need to link `graphqlclient`, `graphqlpeg` for the pre-parsed, pre-validated request AST, and +`graphqlresponse` for the `graphql::response::Value` implementation. \ No newline at end of file diff --git a/src/content/code/language-support/c-c/cppgraphqlgen.md b/src/content/code/language-support/c-c/cppgraphqlgen.md deleted file mode 100644 index 2f11a7c74b..0000000000 --- a/src/content/code/language-support/c-c/cppgraphqlgen.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -name: cppgraphqlgen -description: A C++20 GraphQL schema service and client generator. -url: https://github.com/microsoft/cppgraphqlgen -github: microsoft/cppgraphqlgen ---- - -The easiest way to build and install `cppgraphqlgen` is to use [microsoft/vcpkg](https://github.com/microsoft/vcpkg). -See the [Getting Started](https://github.com/microsoft/vcpkg#getting-started) section of the `vcpkg` README -for details. Once you have that configured, run `vcpkg install cppgraphqlgen` (or `cppgraphqlgen:x64-windows`, -`cppgraphqlgen:x86-windows-static`, etc. depending on your platform). That will build and install all of the -dependencies for `cppgraphqlgen`, and then build `cppgraphqlgen` itself without any other setup. The `cppgraphqlgen` -package (and its dependencies) are advertised to the `CMake` `find_package` function through the -`-DCMAKE_TOOLCHAIN_FILE=<...>/scripts/buildsystems/vcpkg.cmake` parameter/variable. There are more details about -this in the `vcpkg` documentation. diff --git a/src/content/code/language-support/c-c/server/cppgraphqlgen-schemagen.md b/src/content/code/language-support/c-c/server/cppgraphqlgen-schemagen.md new file mode 100644 index 0000000000..4187585de9 --- /dev/null +++ b/src/content/code/language-support/c-c/server/cppgraphqlgen-schemagen.md @@ -0,0 +1,25 @@ +--- +name: cppgraphqlgen-schemagen +description: A C++20 GraphQL service generator using the schema document. +url: https://github.com/microsoft/cppgraphqlgen +github: microsoft/cppgraphqlgen +--- + +Run `schemagen -?` to get a list of options. Many of the files in the [samples](https://github.com/microsoft/cppgraphqlgen/tree/main/samples) directory were generated +with `schemagen`, you can look at [samples/CMakeLists.txt](https://github.com/microsoft/cppgraphqlgen/blob/main/samples/CMakeLists.txt) for a few examples of how to call it: +``` +Usage: schemagen [options] +Command line options: + --version Print the version number + -? [ --help ] Print the command line options + -v [ --verbose ] Verbose output including generated header names as + well as sources + -s [ --schema ] arg Schema definition file path + -p [ --prefix ] arg Prefix to use for the generated C++ filenames + -n [ --namespace ] arg C++ sub-namespace for the generated types + --source-dir arg Target path for the Schema.cpp source file + --header-dir arg Target path for the Schema.h header file + --stubs Unimplemented fields throw runtime exceptions instead + of compiler errors + --no-introspection Do not generate support for Introspection +``` From 78d17c23c5aed952b0e3cb7bd8a727ab54f79709 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 22 Jan 2024 15:56:51 -0800 Subject: [PATCH 5/5] Elaborate the descriptions --- .../language-support/c-c/client/cppgraphqlgen-clientgen.md | 2 +- .../language-support/c-c/server/cppgraphqlgen-schemagen.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/content/code/language-support/c-c/client/cppgraphqlgen-clientgen.md b/src/content/code/language-support/c-c/client/cppgraphqlgen-clientgen.md index 038f2032e0..1fa222f0ac 100644 --- a/src/content/code/language-support/c-c/client/cppgraphqlgen-clientgen.md +++ b/src/content/code/language-support/c-c/client/cppgraphqlgen-clientgen.md @@ -1,6 +1,6 @@ --- name: cppgraphqlgen-clientgen -description: A C++20 GraphQL client request generator and response parser using the schema document. +description: A C++20 GraphQL request client generator and response parser using the schema document. If you want to consume a GraphQL service from a C++ client, you can pre-compile queries and deserialization functions for the expected results. url: https://github.com/microsoft/cppgraphqlgen github: microsoft/cppgraphqlgen --- diff --git a/src/content/code/language-support/c-c/server/cppgraphqlgen-schemagen.md b/src/content/code/language-support/c-c/server/cppgraphqlgen-schemagen.md index 4187585de9..338e60caf6 100644 --- a/src/content/code/language-support/c-c/server/cppgraphqlgen-schemagen.md +++ b/src/content/code/language-support/c-c/server/cppgraphqlgen-schemagen.md @@ -1,12 +1,12 @@ --- name: cppgraphqlgen-schemagen -description: A C++20 GraphQL service generator using the schema document. +description: A C++20 GraphQL service generator using the schema document. You can use this to implement a GraphQL service with resolvers backed by whatever C++ libraries you need. url: https://github.com/microsoft/cppgraphqlgen github: microsoft/cppgraphqlgen --- Run `schemagen -?` to get a list of options. Many of the files in the [samples](https://github.com/microsoft/cppgraphqlgen/tree/main/samples) directory were generated -with `schemagen`, you can look at [samples/CMakeLists.txt](https://github.com/microsoft/cppgraphqlgen/blob/main/samples/CMakeLists.txt) for a few examples of how to call it: +with `schemagen`, you can look at [samples/learn/schema/CMakeLists.txt](https://github.com/microsoft/cppgraphqlgen/blob/main/samples/learn/schema/CMakeLists.txt) for an example of how to call it with the canonical Star Wars sample [schema](https://github.com/microsoft/cppgraphqlgen/blob/main/samples/learn/schema/schema.learn.graphql): ``` Usage: schemagen [options] Command line options: