Skip to content

Commit 33232c0

Browse files
authored
Merge pull request #150 from wravery/main
Rename libraries to graphqlservice and graphqlintrospection
2 parents 9ef4c8d + c65d531 commit 33232c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+332
-313
lines changed

cmake/cppgraphqlgen-config.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ The following import targets are created
1010
::
1111
1212
cppgraphqlgen::graphqlpeg
13+
cppgraphqlgen::graphqlresponse
1314
cppgraphqlgen::graphqlservice
15+
cppgraphqlgen::graphqlintrospection
1416
cppgraphqlgen::graphqljson
1517
cppgraphqlgen::schemagen
1618
#]=======================================================================]

cmake/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.4.1
1+
3.5.0

include/Validation.h

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ struct ValidateArgument
2424
ValidateType type;
2525
};
2626

27-
using ValidateTypeFieldArguments = internal::sorted_map<std::string_view, ValidateArgument>;
27+
using ValidateTypeFieldArguments = internal::string_view_map<ValidateArgument>;
2828

2929
struct ValidateTypeField
3030
{
3131
ValidateType returnType;
3232
ValidateTypeFieldArguments arguments;
3333
};
3434

35-
using ValidateDirectiveArguments = internal::sorted_map<std::string_view, ValidateArgument>;
35+
using ValidateDirectiveArguments = internal::string_view_map<ValidateArgument>;
3636

3737
struct ValidateDirective
3838
{
@@ -75,7 +75,7 @@ struct ValidateArgumentMap
7575
{
7676
bool operator==(const ValidateArgumentMap& other) const;
7777

78-
internal::sorted_map<std::string_view, ValidateArgumentValuePtr> values;
78+
internal::string_view_map<ValidateArgumentValuePtr> values;
7979
};
8080

8181
using ValidateArgumentVariant = std::variant<ValidateArgumentVariable, response::IntType,
@@ -122,7 +122,7 @@ class ValidateArgumentValueVisitor
122122
std::list<schema_error>& _errors;
123123
};
124124

125-
using ValidateFieldArguments = internal::sorted_map<std::string_view, ValidateArgumentValuePtr>;
125+
using ValidateFieldArguments = internal::string_view_map<ValidateArgumentValuePtr>;
126126

127127
struct ValidateField
128128
{
@@ -137,7 +137,7 @@ struct ValidateField
137137
ValidateFieldArguments arguments;
138138
};
139139

140-
using ValidateTypes = internal::sorted_map<std::string_view, ValidateType>;
140+
using ValidateTypes = internal::string_view_map<ValidateType>;
141141

142142
// ValidateVariableTypeVisitor visits the AST and builds a ValidateType structure representing
143143
// a variable type in an operation definition as if it came from an Introspection query.
@@ -179,11 +179,11 @@ class ValidateExecutableVisitor
179179
static ValidateTypeFieldArguments getArguments(
180180
const std::vector<std::shared_ptr<const schema::InputValue>>& args);
181181

182-
using FieldTypes = internal::sorted_map<std::string_view, ValidateTypeField>;
183-
using TypeFields = internal::sorted_map<std::string_view, FieldTypes>;
182+
using FieldTypes = internal::string_view_map<ValidateTypeField>;
183+
using TypeFields = internal::string_view_map<FieldTypes>;
184184
using InputFieldTypes = ValidateTypeFieldArguments;
185-
using InputTypeFields = internal::sorted_map<std::string_view, InputFieldTypes>;
186-
using EnumValues = internal::sorted_map<std::string_view, internal::sorted_set<std::string_view>>;
185+
using InputTypeFields = internal::string_view_map<InputFieldTypes>;
186+
using EnumValues = internal::string_view_map<internal::string_view_set>;
187187

188188
constexpr bool isScalarType(introspection::TypeKind kind);
189189

@@ -218,15 +218,16 @@ class ValidateExecutableVisitor
218218
const std::shared_ptr<schema::Schema> _schema;
219219
std::list<schema_error> _errors;
220220

221-
using Directives = internal::sorted_map<std::string_view, ValidateDirective>;
222-
using ExecutableNodes = internal::sorted_map<std::string_view, std::reference_wrapper<const peg::ast_node>>;
223-
using FragmentSet = internal::sorted_set<std::string_view>;
224-
using MatchingTypes = internal::sorted_map<std::string_view, internal::sorted_set<std::string_view>>;
225-
using ScalarTypes = internal::sorted_set<std::string_view>;
226-
using VariableDefinitions = internal::sorted_map<std::string_view, std::reference_wrapper<const peg::ast_node>>;
227-
using VariableTypes = internal::sorted_map<std::string_view, ValidateArgument>;
221+
using Directives = internal::string_view_map<ValidateDirective>;
222+
using AstNodeRef = std::reference_wrapper<const peg::ast_node>;
223+
using ExecutableNodes = internal::string_view_map<AstNodeRef>;
224+
using FragmentSet = internal::string_view_set;
225+
using MatchingTypes = internal::string_view_map<internal::string_view_set>;
226+
using ScalarTypes = internal::string_view_set;
227+
using VariableDefinitions = internal::string_view_map<AstNodeRef>;
228+
using VariableTypes = internal::string_view_map<ValidateArgument>;
228229
using OperationVariables = std::optional<VariableTypes>;
229-
using VariableSet = internal::sorted_set<std::string_view>;
230+
using VariableSet = internal::string_view_set;
230231

231232
// These members store Introspection schema information which does not change between queries.
232233
ValidateTypes _operationTypes;
@@ -252,7 +253,7 @@ class ValidateExecutableVisitor
252253
TypeFields _typeFields;
253254
InputTypeFields _inputTypeFields;
254255
ValidateType _scopedType;
255-
internal::sorted_map<std::string_view, ValidateField> _selectionFields;
256+
internal::string_view_map<ValidateField> _selectionFields;
256257
};
257258

258259
} /* namespace graphql::service */

include/graphqlservice/GraphQLSchema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Schema : public std::enable_shared_from_this<Schema>
6767
std::shared_ptr<const ObjectType> _query;
6868
std::shared_ptr<const ObjectType> _mutation;
6969
std::shared_ptr<const ObjectType> _subscription;
70-
internal::sorted_map<std::string_view, size_t> _typeMap;
70+
internal::string_view_map<size_t> _typeMap;
7171
std::vector<std::pair<std::string_view, std::shared_ptr<const BaseType>>> _types;
7272
std::vector<std::shared_ptr<const Directive>> _directives;
7373
internal::sorted_map<std::shared_ptr<const BaseType>, std::shared_ptr<const BaseType>>

include/graphqlservice/GraphQLService.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class Fragment
243243

244244
// Resolvers for complex types need to be able to find fragment definitions anywhere in
245245
// the request document by name.
246-
using FragmentMap = internal::sorted_map<std::string_view, Fragment>;
246+
using FragmentMap = internal::string_view_map<Fragment>;
247247

248248
// Resolver functors take a set of arguments encoded as members on a JSON object
249249
// with an optional selection set for complex types and return a JSON value for
@@ -279,7 +279,7 @@ struct ResolverResult
279279
};
280280

281281
using Resolver = std::function<std::future<ResolverResult>(ResolverParams&&)>;
282-
using ResolverMap = internal::sorted_map<std::string_view, Resolver>;
282+
using ResolverMap = internal::string_view_map<Resolver>;
283283

284284
// Binary data and opaque strings like IDs are encoded in Base64.
285285
class Base64
@@ -498,7 +498,7 @@ GRAPHQLSERVICE_EXPORT response::Value ModifiedArgument<response::Value>::convert
498498

499499
// Each type should handle fragments with type conditions matching its own
500500
// name and any inheritted interfaces.
501-
using TypeNames = internal::sorted_set<std::string_view>;
501+
using TypeNames = internal::string_view_set;
502502

503503
// Object parses argument values, performs variable lookups, expands fragments, evaluates @include
504504
// and @skip directives, and calls through to the resolver functor for each selected field with
@@ -851,7 +851,7 @@ GRAPHQLSERVICE_EXPORT std::future<ResolverResult> ModifiedResult<Object>::conver
851851
FieldResult<std::shared_ptr<Object>>&& result, ResolverParams&& params);
852852
#endif // GRAPHQL_DLLEXPORTS
853853

854-
using TypeMap = internal::sorted_map<std::string_view, std::shared_ptr<Object>>;
854+
using TypeMap = internal::string_view_map<std::shared_ptr<Object>>;
855855

856856
// You can still sub-class RequestState and use that in the state parameter to Request::subscribe
857857
// to add your own state to the service callbacks that you receive while executing the subscription
@@ -1002,7 +1002,7 @@ class Request : public std::enable_shared_from_this<Request>
10021002
const TypeMap _operations;
10031003
std::unique_ptr<ValidateExecutableVisitor> _validation;
10041004
internal::sorted_map<SubscriptionKey, std::shared_ptr<SubscriptionData>> _subscriptions;
1005-
internal::sorted_map<std::string_view, internal::sorted_set<SubscriptionKey>> _listeners;
1005+
internal::string_view_map<internal::sorted_set<SubscriptionKey>> _listeners;
10061006
SubscriptionKey _nextKey = 0;
10071007
};
10081008

include/graphqlservice/internal/SortedMap.h

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
#define SORTEDMAP_H
88

99
#include <algorithm>
10+
#include <functional>
1011
#include <initializer_list>
1112
#include <stdexcept>
1213
#include <tuple>
1314
#include <vector>
1415

1516
namespace graphql::internal {
1617

17-
template <class K, class V>
18+
template <class K, class V, class Compare = std::less<K>>
1819
class sorted_map
1920
{
2021
public:
@@ -29,7 +30,7 @@ class sorted_map
2930
: _data { init }
3031
{
3132
std::sort(_data.begin(), _data.end(), [](const auto& lhs, const auto& rhs) noexcept {
32-
return lhs.first < rhs.first;
33+
return Compare {}(lhs.first, rhs.first);
3334
});
3435
}
3536

@@ -89,7 +90,7 @@ class sorted_map
8990
end(),
9091
key,
9192
[](sorted_map_key lhs, sorted_map_key rhs) noexcept {
92-
return lhs.key < rhs.key;
93+
return Compare {}(lhs.key, rhs.key);
9394
});
9495

9596
return itr == itrEnd ? _data.end() : itr;
@@ -111,17 +112,15 @@ class sorted_map
111112
_data.end(),
112113
key,
113114
[](sorted_map_key lhs, sorted_map_key rhs) noexcept {
114-
return lhs.key < rhs.key;
115+
return Compare {}(lhs.key, rhs.key);
115116
});
116117

117118
if (itr != itrEnd)
118119
{
119120
return { itr, false };
120121
}
121122

122-
return { _data.emplace(itrEnd,
123-
std::move(key),
124-
V { std::forward<ValueArgs>(args)... }),
123+
return { _data.emplace(itrEnd, std::move(key), V { std::forward<ValueArgs>(args)... }),
125124
true };
126125
}
127126

@@ -131,7 +130,7 @@ class sorted_map
131130
_data.end(),
132131
key,
133132
[](sorted_map_key lhs, sorted_map_key rhs) noexcept {
134-
return lhs.key < rhs.key;
133+
return Compare {}(lhs.key, rhs.key);
135134
});
136135

137136
if (itr == itrEnd)
@@ -163,7 +162,7 @@ class sorted_map
163162
_data.end(),
164163
key,
165164
[](sorted_map_key lhs, sorted_map_key rhs) noexcept {
166-
return lhs.key < rhs.key;
165+
return Compare {}(lhs.key, rhs.key);
167166
});
168167

169168
if (itr != itrEnd)
@@ -182,7 +181,7 @@ class sorted_map
182181
_data.end(),
183182
key,
184183
[](sorted_map_key lhs, sorted_map_key rhs) noexcept {
185-
return lhs.key < rhs.key;
184+
return Compare {}(lhs.key, rhs.key);
186185
});
187186

188187
if (itr == itrEnd)
@@ -212,7 +211,7 @@ class sorted_map
212211
vector_type _data;
213212
};
214213

215-
template <class K>
214+
template <class K, class Compare = std::less<K>>
216215
class sorted_set
217216
{
218217
public:
@@ -225,8 +224,8 @@ class sorted_set
225224
sorted_set(std::initializer_list<K> init)
226225
: _data { init }
227226
{
228-
std::sort(_data.begin(), _data.end(), [](const auto& lhs, const auto& rhs) noexcept {
229-
return lhs < rhs;
227+
std::sort(_data.begin(), _data.end(), [](const K& lhs, const K& rhs) noexcept {
228+
return Compare {}(lhs, rhs);
230229
});
231230
}
232231

@@ -283,8 +282,8 @@ class sorted_set
283282
const_iterator find(const K& key) const noexcept
284283
{
285284
const auto [itr, itrEnd] =
286-
std::equal_range(begin(), end(), key, [](const auto& lhs, const auto& rhs) noexcept {
287-
return lhs < rhs;
285+
std::equal_range(begin(), end(), key, [](const K& lhs, const K& rhs) noexcept {
286+
return Compare {}(lhs, rhs);
288287
});
289288

290289
return itr == itrEnd ? _data.end() : itr;
@@ -305,7 +304,7 @@ class sorted_set
305304
_data.end(),
306305
key,
307306
[](const auto& lhs, const auto& rhs) noexcept {
308-
return lhs < rhs;
307+
return Compare {}(lhs, rhs);
309308
});
310309

311310
if (itr != itrEnd)
@@ -321,8 +320,8 @@ class sorted_set
321320
const auto [itr, itrEnd] = std::equal_range(_data.begin(),
322321
_data.end(),
323322
key,
324-
[](const auto& lhs, const auto& rhs) noexcept {
325-
return lhs < rhs;
323+
[](const K& lhs, const K& rhs) noexcept {
324+
return Compare {}(lhs, rhs);
326325
});
327326

328327
if (itr == itrEnd)
@@ -350,6 +349,18 @@ class sorted_set
350349
vector_type _data;
351350
};
352351

352+
struct shorter_or_less
353+
{
354+
constexpr bool operator()(const std::string_view& lhs, const std::string_view& rhs) const
355+
{
356+
return lhs.size() == rhs.size() ? lhs < rhs : lhs.size() < rhs.size();
357+
}
358+
};
359+
360+
template <class V>
361+
using string_view_map = sorted_map<std::string_view, V, shorter_or_less>;
362+
using string_view_set = sorted_set<std::string_view, shorter_or_less>;
363+
353364
} // namespace graphql::internal
354365

355366
#endif // SORTEDMAP_H

include/graphqlservice/internal/Version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
namespace graphql::internal {
1212

13-
constexpr std::string_view FullVersion { "3.4.1" };
13+
constexpr std::string_view FullVersion { "3.5.0" };
1414

1515
constexpr size_t MajorVersion = 3;
16-
constexpr size_t MinorVersion = 4;
17-
constexpr size_t PatchVersion = 1;
16+
constexpr size_t MinorVersion = 5;
17+
constexpr size_t PatchVersion = 0;
1818

1919
} // namespace graphql::internal
2020

include/graphqlservice/introspection/IntrospectionSchema.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
#include "graphqlservice/GraphQLSchema.h"
1212
#include "graphqlservice/GraphQLService.h"
1313

14-
// Check if the library version is compatible with schemagen 3.4.1
14+
// Check if the library version is compatible with schemagen 3.5.0
1515
static_assert(graphql::internal::MajorVersion == 3, "regenerate with schemagen: major version mismatch");
16-
static_assert(graphql::internal::MinorVersion == 4, "regenerate with schemagen: minor version mismatch");
16+
static_assert(graphql::internal::MinorVersion == 5, "regenerate with schemagen: minor version mismatch");
1717

1818
// clang-format off
1919
#ifdef GRAPHQL_DLLEXPORTS

res/SchemaGen.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
#include <winver.h>
55

6-
#define SCHEMAGEN_RC_VERSION 3,4,1,0
7-
#define SCHEMAGEN_RC_VERSION_STR "3.4.1"
6+
#define SCHEMAGEN_RC_VERSION 3,5,0,0
7+
#define SCHEMAGEN_RC_VERSION_STR "3.5.0"
88

99
#ifndef DEBUG
1010
#define VER_DEBUG 0

res/graphqlservice_nointrospection_version.rc renamed to res/graphqlintrospection_version.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
#include <winver.h>
55

6-
#define GRAPHQL_RC_VERSION 3,4,1,0
7-
#define GRAPHQL_RC_VERSION_STR "3.4.1"
6+
#define GRAPHQL_RC_VERSION 3,5,0,0
7+
#define GRAPHQL_RC_VERSION_STR "3.5.0"
88

99
#ifndef DEBUG
1010
#define VER_DEBUG 0
@@ -28,9 +28,9 @@ BEGIN
2828
VALUE "CompanyName", "Microsoft Corporation"
2929
VALUE "FileDescription", "Shared library for https://github.com/microsoft/cppgraphqlgen"
3030
VALUE "FileVersion", GRAPHQL_RC_VERSION_STR
31-
VALUE "InternalName", "graphqlservice_nointrospection"
31+
VALUE "InternalName", "graphqlintrospection"
3232
VALUE "LegalCopyright", "Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License."
33-
VALUE "OriginalFilename", "graphqlservice_nointrospection.dll"
33+
VALUE "OriginalFilename", "graphqlintrospection.dll"
3434
VALUE "ProductName", "CppGraphQLGen"
3535
VALUE "ProductVersion", GRAPHQL_RC_VERSION_STR
3636
END

0 commit comments

Comments
 (0)