Skip to content

Fix source lifetime and preserve input strings in response::IdType #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.4.1
4.5.0
5 changes: 3 additions & 2 deletions include/graphqlservice/internal/Base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ class Base64
const std::vector<std::uint8_t>& bytes);

enum class [[nodiscard]] Comparison {
// Valid Base64 always compares as less than non-empty invalid Base64.
InvalidBase64 = -2,

LessThan = -1,
EqualTo = 0,
GreaterThan = 1,

InvalidBase64 = 2,
};

// Compare a set of bytes to a possible Base64 string without performing any heap allocations.
Expand Down
5 changes: 0 additions & 5 deletions include/graphqlservice/internal/Grammar.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@

#include "graphqlservice/internal/SyntaxTree.h"

#define TAO_PEGTL_NAMESPACE tao::graphqlpeg

#include <tao/pegtl.hpp>
#include <tao/pegtl/contrib/parse_tree.hpp>

#include <functional>

namespace graphql::peg {
Expand Down
30 changes: 0 additions & 30 deletions include/graphqlservice/internal/SyntaxTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,36 +86,6 @@ class [[nodiscard]] ast_node : public parse_tree::basic_node<ast_node>
mutable std::unique_ptr<unescaped_t> _unescaped;
};

template <class ParseInput>
class [[nodiscard]] depth_limit_input : public ParseInput
{
public:
template <typename... Args>
explicit depth_limit_input(size_t depthLimit, Args&&... args) noexcept
: ParseInput(std::forward<Args>(args)...)
, _depthLimit(depthLimit)
{
}

size_t depthLimit() const noexcept
{
return _depthLimit;
}

size_t selectionSetDepth = 0;

private:
const size_t _depthLimit;
};

using ast_file = depth_limit_input<file_input<>>;
using ast_memory = depth_limit_input<memory_input<>>;

struct [[nodiscard]] ast_input
{
std::variant<std::vector<char>, std::unique_ptr<ast_file>, std::string_view> data;
};

} // namespace graphql::peg

#endif // GRAPHQLSYNTAXTREE_H
6 changes: 3 additions & 3 deletions include/graphqlservice/internal/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

namespace graphql::internal {

constexpr std::string_view FullVersion { "4.4.1" };
constexpr std::string_view FullVersion { "4.5.0" };

constexpr size_t MajorVersion = 4;
constexpr size_t MinorVersion = 4;
constexpr size_t PatchVersion = 1;
constexpr size_t MinorVersion = 5;
constexpr size_t PatchVersion = 0;

} // namespace graphql::internal

Expand Down
4 changes: 2 additions & 2 deletions include/graphqlservice/introspection/IntrospectionSchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

#include "graphqlservice/internal/Schema.h"

// Check if the library version is compatible with schemagen 4.4.0
// Check if the library version is compatible with schemagen 4.5.0
static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch");
static_assert(graphql::internal::MinorVersion == 4, "regenerate with schemagen: minor version mismatch");
static_assert(graphql::internal::MinorVersion == 5, "regenerate with schemagen: minor version mismatch");

#include <array>
#include <memory>
Expand Down
4 changes: 2 additions & 2 deletions res/ClientGen.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include <winver.h>

#define GRAPHQL_RC_VERSION 4,4,1,0
#define GRAPHQL_RC_VERSION_STR "4.4.1"
#define GRAPHQL_RC_VERSION 4,5,0,0
#define GRAPHQL_RC_VERSION_STR "4.5.0"

#ifndef DEBUG
#define VER_DEBUG 0
Expand Down
4 changes: 2 additions & 2 deletions res/SchemaGen.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include <winver.h>

#define GRAPHQL_RC_VERSION 4,4,1,0
#define GRAPHQL_RC_VERSION_STR "4.4.1"
#define GRAPHQL_RC_VERSION 4,5,0,0
#define GRAPHQL_RC_VERSION_STR "4.5.0"

#ifndef DEBUG
#define VER_DEBUG 0
Expand Down
4 changes: 2 additions & 2 deletions res/graphqlclient_version.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include <winver.h>

#define GRAPHQL_RC_VERSION 4,4,1,0
#define GRAPHQL_RC_VERSION_STR "4.4.1"
#define GRAPHQL_RC_VERSION 4,5,0,0
#define GRAPHQL_RC_VERSION_STR "4.5.0"

#ifndef DEBUG
#define VER_DEBUG 0
Expand Down
4 changes: 2 additions & 2 deletions res/graphqljson_version.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include <winver.h>

#define GRAPHQL_RC_VERSION 4,4,1,0
#define GRAPHQL_RC_VERSION_STR "4.4.1"
#define GRAPHQL_RC_VERSION 4,5,0,0
#define GRAPHQL_RC_VERSION_STR "4.5.0"

#ifndef DEBUG
#define VER_DEBUG 0
Expand Down
4 changes: 2 additions & 2 deletions res/graphqlpeg_version.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include <winver.h>

#define GRAPHQL_RC_VERSION 4,4,1,0
#define GRAPHQL_RC_VERSION_STR "4.4.1"
#define GRAPHQL_RC_VERSION 4,5,0,0
#define GRAPHQL_RC_VERSION_STR "4.5.0"

#ifndef DEBUG
#define VER_DEBUG 0
Expand Down
4 changes: 2 additions & 2 deletions res/graphqlresponse_version.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include <winver.h>

#define GRAPHQL_RC_VERSION 4,4,1,0
#define GRAPHQL_RC_VERSION_STR "4.4.1"
#define GRAPHQL_RC_VERSION 4,5,0,0
#define GRAPHQL_RC_VERSION_STR "4.5.0"

#ifndef DEBUG
#define VER_DEBUG 0
Expand Down
4 changes: 2 additions & 2 deletions res/graphqlservice_version.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include <winver.h>

#define GRAPHQL_RC_VERSION 4,4,1,0
#define GRAPHQL_RC_VERSION_STR "4.4.1"
#define GRAPHQL_RC_VERSION 4,5,0,0
#define GRAPHQL_RC_VERSION_STR "4.5.0"

#ifndef DEBUG
#define VER_DEBUG 0
Expand Down
4 changes: 2 additions & 2 deletions samples/client/benchmark/BenchmarkClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

#include "graphqlservice/internal/Version.h"

// Check if the library version is compatible with clientgen 4.4.0
// Check if the library version is compatible with clientgen 4.5.0
static_assert(graphql::internal::MajorVersion == 4, "regenerate with clientgen: major version mismatch");
static_assert(graphql::internal::MinorVersion == 4, "regenerate with clientgen: minor version mismatch");
static_assert(graphql::internal::MinorVersion == 5, "regenerate with clientgen: minor version mismatch");

#include <optional>
#include <string>
Expand Down
4 changes: 2 additions & 2 deletions samples/client/multiple/MultipleQueriesClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

#include "graphqlservice/internal/Version.h"

// Check if the library version is compatible with clientgen 4.4.0
// Check if the library version is compatible with clientgen 4.5.0
static_assert(graphql::internal::MajorVersion == 4, "regenerate with clientgen: major version mismatch");
static_assert(graphql::internal::MinorVersion == 4, "regenerate with clientgen: minor version mismatch");
static_assert(graphql::internal::MinorVersion == 5, "regenerate with clientgen: minor version mismatch");

#include <optional>
#include <string>
Expand Down
4 changes: 2 additions & 2 deletions samples/client/mutate/MutateClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

#include "graphqlservice/internal/Version.h"

// Check if the library version is compatible with clientgen 4.4.0
// Check if the library version is compatible with clientgen 4.5.0
static_assert(graphql::internal::MajorVersion == 4, "regenerate with clientgen: major version mismatch");
static_assert(graphql::internal::MinorVersion == 4, "regenerate with clientgen: minor version mismatch");
static_assert(graphql::internal::MinorVersion == 5, "regenerate with clientgen: minor version mismatch");

#include <optional>
#include <string>
Expand Down
4 changes: 2 additions & 2 deletions samples/client/nestedinput/NestedInputClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

#include "graphqlservice/internal/Version.h"

// Check if the library version is compatible with clientgen 4.4.0
// Check if the library version is compatible with clientgen 4.5.0
static_assert(graphql::internal::MajorVersion == 4, "regenerate with clientgen: major version mismatch");
static_assert(graphql::internal::MinorVersion == 4, "regenerate with clientgen: minor version mismatch");
static_assert(graphql::internal::MinorVersion == 5, "regenerate with clientgen: minor version mismatch");

#include <optional>
#include <string>
Expand Down
4 changes: 2 additions & 2 deletions samples/client/query/QueryClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

#include "graphqlservice/internal/Version.h"

// Check if the library version is compatible with clientgen 4.4.0
// Check if the library version is compatible with clientgen 4.5.0
static_assert(graphql::internal::MajorVersion == 4, "regenerate with clientgen: major version mismatch");
static_assert(graphql::internal::MinorVersion == 4, "regenerate with clientgen: minor version mismatch");
static_assert(graphql::internal::MinorVersion == 5, "regenerate with clientgen: minor version mismatch");

#include <optional>
#include <string>
Expand Down
4 changes: 2 additions & 2 deletions samples/client/subscribe/SubscribeClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

#include "graphqlservice/internal/Version.h"

// Check if the library version is compatible with clientgen 4.4.0
// Check if the library version is compatible with clientgen 4.5.0
static_assert(graphql::internal::MajorVersion == 4, "regenerate with clientgen: major version mismatch");
static_assert(graphql::internal::MinorVersion == 4, "regenerate with clientgen: minor version mismatch");
static_assert(graphql::internal::MinorVersion == 5, "regenerate with clientgen: minor version mismatch");

#include <optional>
#include <string>
Expand Down
12 changes: 6 additions & 6 deletions samples/learn/QueryData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@ std::shared_ptr<object::Character> Query::getHero(std::optional<Episode> episode

std::shared_ptr<object::Human> Query::getHuman(const response::IdType& idArg) const noexcept
{
std::shared_ptr<Human> result;
std::shared_ptr<object::Human> result;

if (const auto itr = humans_.find(idArg); itr != humans_.end())
{
result = itr->second;
result = std::make_shared<object::Human>(itr->second);
}

return std::make_shared<object::Human>(std::move(result));
return result;
}

std::shared_ptr<object::Droid> Query::getDroid(const response::IdType& idArg) const noexcept
{
std::shared_ptr<Droid> result;
std::shared_ptr<object::Droid> result;

if (const auto itr = droids_.find(idArg); itr != droids_.end())
{
result = itr->second;
result = std::make_shared<object::Droid>(itr->second);
}

return std::make_shared<object::Droid>(std::move(result));
return result;
}

} // namespace graphql::learn
4 changes: 2 additions & 2 deletions samples/learn/schema/StarWarsSchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

#include "graphqlservice/internal/Schema.h"

// Check if the library version is compatible with schemagen 4.4.0
// Check if the library version is compatible with schemagen 4.5.0
static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch");
static_assert(graphql::internal::MinorVersion == 4, "regenerate with schemagen: minor version mismatch");
static_assert(graphql::internal::MinorVersion == 5, "regenerate with schemagen: minor version mismatch");

#include <array>
#include <memory>
Expand Down
4 changes: 2 additions & 2 deletions samples/today/nointrospection/TodaySchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

#include "graphqlservice/internal/Schema.h"

// Check if the library version is compatible with schemagen 4.4.0
// Check if the library version is compatible with schemagen 4.5.0
static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch");
static_assert(graphql::internal::MinorVersion == 4, "regenerate with schemagen: minor version mismatch");
static_assert(graphql::internal::MinorVersion == 5, "regenerate with schemagen: minor version mismatch");

#include <array>
#include <memory>
Expand Down
4 changes: 2 additions & 2 deletions samples/today/schema/TodaySchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

#include "graphqlservice/internal/Schema.h"

// Check if the library version is compatible with schemagen 4.4.0
// Check if the library version is compatible with schemagen 4.5.0
static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch");
static_assert(graphql::internal::MinorVersion == 4, "regenerate with schemagen: minor version mismatch");
static_assert(graphql::internal::MinorVersion == 5, "regenerate with schemagen: minor version mismatch");

#include <array>
#include <memory>
Expand Down
4 changes: 2 additions & 2 deletions samples/validation/schema/ValidationSchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

#include "graphqlservice/internal/Schema.h"

// Check if the library version is compatible with schemagen 4.4.0
// Check if the library version is compatible with schemagen 4.5.0
static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch");
static_assert(graphql::internal::MinorVersion == 4, "regenerate with schemagen: minor version mismatch");
static_assert(graphql::internal::MinorVersion == 5, "regenerate with schemagen: minor version mismatch");

#include <array>
#include <memory>
Expand Down
15 changes: 7 additions & 8 deletions src/GraphQLResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@ bool IdType::operator<(const IdType& rhs) const noexcept
}

return (std::holds_alternative<ByteData>(_data)
? internal::Base64::compareBase64(std::get<ByteData>(_data),
std::get<OpaqueString>(rhs._data))
: internal::Base64::compareBase64(std::get<ByteData>(rhs._data),
std::get<OpaqueString>(_data)))
> internal::Base64::Comparison::EqualTo;
? (internal::Base64::compareBase64(std::get<ByteData>(_data),
std::get<OpaqueString>(rhs._data))
< internal::Base64::Comparison::EqualTo)
: (internal::Base64::compareBase64(std::get<ByteData>(rhs._data),
std::get<OpaqueString>(_data)))
> internal::Base64::Comparison::EqualTo);
}

bool IdType::isBase64() const noexcept
Expand Down Expand Up @@ -881,9 +882,7 @@ IdType Value::release<IdType>()
{
auto stringValue = std::move(stringData.string);

return internal::Base64::validateBase64(stringValue)
? IdType { internal::Base64::fromBase64(stringValue) }
: IdType { std::move(stringValue) };
return IdType { std::move(stringValue) };
}
}
else if (std::holds_alternative<IdType>(_data))
Expand Down
Loading