Skip to content

Commit b560cba

Browse files
authored
Merge pull request #91 from wravery/master
Doc updates and a bug fix for defaultValue in Introspection
2 parents 766d3b8 + 36bcffe commit b560cba

File tree

7 files changed

+25
-16
lines changed

7 files changed

+25
-16
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ Command line options:
108108
--separate-files Generate separate files for each of the types
109109
```
110110

111-
I've only tested this with Boost 1.69.0, but I expect it will work fine with most other versions. The Boost dependencies
112-
are only used by the `schemagen` utility at or before your build, so you probably don't need to redistribute it or the
113-
Boost libraries with your project.
111+
I've tested this with several versions of Boost going back to 1.65.0. I expect it will work fine with most versions of
112+
Boost after that. The Boost dependencies are only used by the `schemagen` utility at or before your build, so you
113+
probably don't need to redistribute it or the Boost libraries with your project.
114114

115115
If you are building shared libraries on Windows (DLLs) using vcpkg or `BUILD_SHARED_LIBS=ON` in CMake, be aware that this
116116
adds a runtime dependency on a Boost DLL. The `schemagen` tool won't run without it. However, in addition to automating
@@ -148,10 +148,10 @@ All of the generated files are in the [samples](samples/) directory. There are t
148148
the generated code, one which creates a single pair of files (`samples/unified/`), and one which uses the
149149
`--separate-files` flag with `schemagen` to generate individual header and source files (`samples/separate/`)
150150
for each of the object types which need to be implemeneted. The only difference between
151-
[UnifiedToday.h](samples/today/UnifiedToday.h)
152-
and [SeparateToday.h](samples/today/SeparateToday.h) should be that the `SeparateToday` use a generated
153-
[TodayObjects.h](samples/separate/TodayObjects.h) convenience header which includes all of the inidividual
154-
object header along with the rest of the schema in [TodaySchema.h](samples/separate/TodaySchema.h).
151+
[TodayMock.h](samples/today/TodayMock.h) with and without `IMPL_SEPARATE_TODAY` defined should be that the
152+
`--separate-files` option generates a [TodayObjects.h](samples/separate/TodayObjects.h) convenience header
153+
which includes all of the inidividual object header along with the rest of the schema in
154+
[TodaySchema.h](samples/separate/TodaySchema.h).
155155

156156
# Build and Test
157157

doc/parsing.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ The document must use a UTF-8 encoding. If you need to handle documents in
4646
another encoding you will need to convert them to UTF-8 before parsing.
4747

4848
If you need to convert the encoding at runtime, I would recommend using
49-
`std::wstring_convert`, with the cavevat that it has been
49+
`std::wstring_convert`, with the caveat that it has been
5050
[deprecated](https://en.cppreference.com/w/cpp/locale/wstring_convert) in
5151
C++17. You could keep using it until it is replaced in the standard, you
5252
could use a portable non-standard library like
5353
[ICU](http://site.icu-project.org/design/cpp), or you could use
5454
platform-specific conversion routines like
55-
[WideCharToMultiByte](https://docs.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-widechartomultibyte) on Windows.
55+
[WideCharToMultiByte](https://docs.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-widechartomultibyte)
56+
on Windows instead.

doc/resolvers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ schema {
3434

3535
Executing a query or mutation starts by calling `Request::resolve` from [GraphQLService.h](../include/graphqlservice/GraphQLService.h):
3636
```cpp
37-
std::future<response::Value> resolve(const std::shared_ptr<RequestState>& state, const peg::ast_node& root, const std::string& operationName, response::Value&& variables) const;
37+
std::future<response::Value> resolve(const std::shared_ptr<RequestState>& state, peg::ast& query, const std::string& operationName, response::Value&& variables) const;
3838
```
3939
By default, the `std::future` results are resolved on-demand but synchronously,
4040
using `std::launch::deferred` with the `std::async` function. You can also use
4141
an override of `Request::resolve` which lets you substitute the
4242
`std::launch::async` option to begin executing the query on multiple threads
4343
in parallel:
4444
```cpp
45-
std::future<response::Value> resolve(std::launch launch, const std::shared_ptr<RequestState>& state, const peg::ast_node& root, const std::string& operationName, response::Value&& variables) const;
45+
std::future<response::Value> resolve(std::launch launch, const std::shared_ptr<RequestState>& state, peg::ast& query, const std::string& operationName, response::Value&& variables) const;
4646
```
4747

4848
### `graphql::service::Request` and `graphql::<schema>::Operations`

doc/subscriptions.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ for every required field in the subscription `query`.
6464
void deliver(const SubscriptionName& name, const SubscriptionFilterCallback& apply, const std::shared_ptr<Object>& subscriptionObject) const;
6565
```
6666
67+
By default, `deliver` invokes all of the `SubscriptionCallback` listeners with `std::future`
68+
payloads which are resolved on-demand but synchronously, using `std::launch::deferred` with the
69+
`std::async` function. There's also a version of each overload which lets you substitute the
70+
`std::launch::async` option to begin executing the queries and invoke the callbacks on multiple
71+
threads in parallel:
72+
```cpp
73+
void deliver(std::launch launch, const SubscriptionName& name, const std::shared_ptr<Object>& subscriptionObject) const;
74+
void deliver(std::launch launch, const SubscriptionName& name, const SubscriptionArguments& arguments, const std::shared_ptr<Object>& subscriptionObject) const;
75+
void deliver(std::launch launch, const SubscriptionName& name, const SubscriptionFilterCallback& apply, const std::shared_ptr<Object>& subscriptionObject) const;
76+
```
77+
6778
## Handling Multiple Operation Types
6879

6980
Some service implementations (e.g. Apollo over HTTP) use a single pipe to

samples/introspection/IntrospectionSchema.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ void AddTypesToSchema(const std::shared_ptr<introspection::Schema>& schema)
672672
R"gql(FIELD_DEFINITION)gql",
673673
R"gql(ENUM_VALUE)gql"
674674
}), std::vector<std::shared_ptr<introspection::InputValue>>({
675-
std::make_shared<introspection::InputValue>("reason", R"md()md", schema->LookupType("String"), R"gql(No longer supported)gql")
675+
std::make_shared<introspection::InputValue>("reason", R"md()md", schema->LookupType("String"), R"gql("No longer supported")gql")
676676
})));
677677
}
678678

src/GraphQLTree.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ struct ast_selector<string_value>
202202
}
203203
}
204204

205-
n->remove_content();
206205
n->children.clear();
207206
}
208207
};

src/SchemaGenerator.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,9 +1296,7 @@ InputFieldList Generator::getInputFields(const std::vector<std::unique_ptr<peg::
12961296

12971297
defaultValue.visit(*child->children.back());
12981298
field.defaultValue = defaultValue.getValue();
1299-
field.defaultValueString = child->children.back()->unescaped.empty()
1300-
? child->children.back()->string_view()
1301-
: child->children.back()->unescaped;
1299+
field.defaultValueString = child->children.back()->string_view();
13021300

13031301
defaultValueLocation = { position.line, position.byte_in_line };
13041302
}

0 commit comments

Comments
 (0)