Skip to content

Releases: microsoft/cppgraphqlgen

Feature release: Query Validation

08 Mar 18:21
3ca273a
Compare
Choose a tag to compare

This is a comprehensive fix for #69. Per the spec, the service ought to validate every query before execution to make sure the results are not ambiguous.

There may still be runtime field errors that this doesn't catch, and since the last time I looked at that section of the spec there also seems to be a lot more guidance about how to format the errors. I added locations to all of the errors I could, and a path to the runtime field errors.

In the process of building the validation feature with TDD based on the Examples and Counter Examples in the spec, I found a few bugs in SchemaGenerator as well and fixed those. The validation relies on Introspection and helped flush those out.

Validation can be performed separately with Request::validate, or you can use the new Request::resolve overloads which take a peg::ast& query parameter instead of a const peg::ast_node& root parameter, they will make sure the query is validated once before executing it. The old Request::resolve overloads are still there for backwards compatibility, but they have been marked as [[deprecated]]. They will go away the next time there's a major version release.

Fix a few bugs in schemagen and add documentation

30 Sep 02:07
a70d822
Compare
Choose a tag to compare

If v3.0.3 was working for your GraphQL schema already, this update should not change any runtime behavior. It fixes a couple of bugs in schemagen (#72 and #74), and it adds documentation in the doc sub-directory which among other things clarifies how to handle subscriptions (#67).

Various bug fixes including a crash in schema_exception destructor

01 Sep 05:24
ab32d4f
Compare
Choose a tag to compare

Most notably, this release should be better at bubbling up schema_exception and preserving error messages from deeper in the query resolution process.

At least on Windows with VS 2019, the copy constructor hiding that I tried for the fix to #63 broke the contract for std::exception and resulted in a crash when the schema_exception was copied but didn't invoke the default copy of the _errors member. That bug has been in there since v3.0.1.

Work around `std::vector<std::string>` linker issue

13 Aug 03:18
d296d29
Compare
Choose a tag to compare

I changed the semantics of the service::schema_exception constructors a bit in order to work around what seems to be a linker bug. Using type inference compiles OK with the syntax service::schema_exception({ std::string(...) }), but it complains that it can't find the definition of std::vector<std::string> if there are no explicitly constructed instances of that type.

Oddly enough, switching to initializer syntax with an extra {} instead of '()' for the constructor (e.g. service::schema_exception { { std::string(...) } }) seems to be enough of a hint to the compiler/linker to include the necessary pieces of std::vector<std::string>. This should be backwards compatible with code that still uses the old syntax, so not a breaking change, but if you continue using that syntax you might encounter the same linker bug (or whatever subtle C++ behavior this is).

Update to the latest version of PEGTL

10 Aug 20:17
d89e010
Compare
Choose a tag to compare

I pulled the latest commits from PEGTL and found that the parse_tree::basic_node::is<> method was renamed to parse_tree::basic_node::is_type<>.

Update to C++17

07 May 17:42
Compare
Choose a tag to compare

Highlights from #52:

Adopting C++17

  • Move to PEGTL master/3.0.0 (not yet officially released)
  • Use std::variant for response::Value
  • Replace std::unique_ptr for nullable fields with std::optional

Schemagen improvements

  • Make NYI stub generation optional
  • Split the class definitions/declarations into separate files. May also help with making the NYI stubs optional (i.e. decide whether or not to compile and link them individually).
  • Improve error handling/reporting.
  • Add command line options for things like defining a target directory.
  • Change the names of the generated Mutation accessors to something like applyFieldName. Calling everything getFieldName feels strange when performing a mutation.

Miscellaneous

  • Introduce service::FieldResult which handles returning either by value of T or as a std::future<T>
  • Let the caller specify the std::launch policy for the Request::resolve top-level call.
  • Build a separate library target for the grammar/AST.
  • Replace std::string with std::string_view where appropriate.
  • Replace ast<std::string> with ast<std::vector<char>> to deal with small-string-optimization issues rather than reserving extra space when the string is too short.
  • Replace the facebook::graphql namespace with just graphql for the sake of brevity.

Implement default NYI stubs

05 Mar 19:53
2e14371
Compare
Choose a tag to compare

I was finding it difficult to get started with a new schema or to add types to an existing schema since all of the pure virtual methods would need to be defined on the subclass before it could even link. The new feature in this release is that schemagen will generate stub implementations which throw a std::runtime_error exception and bubble up a "not implemented" message to the field error if they are not overridden.

This release also includes the fix for Issue #44 handling schema extensions and PR #42 which cleans up some of the USE_RAPIDJSON handling in CMake.

Fix schema extension handling

05 Mar 19:46
Compare
Choose a tag to compare

Bug fix release with the fix for #44 in schemagen.

Fix empty list and object results

07 Feb 08:02
7e3acf9
Compare
Choose a tag to compare

Results for empty lists or types with no members should be included in the results. See issue #39 for more details.

Fix empty list and object results

07 Feb 08:01
Compare
Choose a tag to compare

Results for empty lists or types with no members should be included in the results. See issue #39 for more details.