Skip to content

Commit c9b305a

Browse files
committed
Docs: Removed extra indentation from code snippets
1 parent 3d98d36 commit c9b305a

File tree

1 file changed

+35
-36
lines changed

1 file changed

+35
-36
lines changed

doc/getting_started.md

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -65,31 +65,30 @@ Strictly speaking, the only requirements are the function that the generated sch
6565
By exploring the schemagen `QueryObject.h` file and searching `static_assert` you can notice how there will be two matches, reported below:
6666

6767
``` cpp
68-
[[nodiscard("unnecessary call")]] service::AwaitableScalar<std::vector<std::string>> getNames(service::FieldParams&& params) const override
69-
{
70-
if constexpr (methods::QueryHas::getNamesWithParams<T>)
71-
{
72-
return { _pimpl->getNames(std::move(params)) };
73-
}
74-
else
75-
{
76-
static_assert(methods::QueryHas::getNames<T>, R"msg(Query::getNames is not implemented)msg");
77-
return { _pimpl->getNames() };
78-
}
79-
}
80-
81-
[[nodiscard("unnecessary call")]] service::AwaitableObject<std::vector<std::shared_ptr<Thing>>> getStuff(service::FieldParams&& params, std::optional<std::string>&& idArg) const override
82-
{
83-
if constexpr (methods::QueryHas::getStuffWithParams<T>)
84-
{
85-
return { _pimpl->getStuff(std::move(params), std::move(idArg)) };
86-
}
87-
else
88-
{
89-
static_assert(methods::QueryHas::getStuff<T>, R"msg(Query::getStuff is not implemented)msg");
90-
return { _pimpl->getStuff(std::move(idArg)) };
91-
}
92-
}
68+
[[nodiscard("unnecessary call")]] service::AwaitableScalar<std::vector<std::string>> getNames(service::FieldParams&& params) const override
69+
{
70+
if constexpr (methods::QueryHas::getNamesWithParams<T>)
71+
{
72+
return { _pimpl->getNames(std::move(params)) };
73+
}
74+
else
75+
{
76+
static_assert(methods::QueryHas::getNames<T>, R"msg(Query::getNames is not implemented)msg");
77+
return { _pimpl->getNames() };
78+
}
79+
}
80+
[[nodiscard("unnecessary call")]] service::AwaitableObject<std::vector<std::shared_ptr<Thing>>> getStuff(service::FieldParams&& params, std::optional<std::string>&& idArg) const override
81+
{
82+
if constexpr (methods::QueryHas::getStuffWithParams<T>)
83+
{
84+
return { _pimpl->getStuff(std::move(params), std::move(idArg)) };
85+
}
86+
else
87+
{
88+
static_assert(methods::QueryHas::getStuff<T>, R"msg(Query::getStuff is not implemented)msg");
89+
return { _pimpl->getStuff(std::move(idArg)) };
90+
}
91+
}
9392
```
9493

9594
these two blocks of code are responsible for checking whether you class, of which instance you will be providing to this object, satisfies the requirement of having certain methods.
@@ -218,17 +217,17 @@ These methods may throw an exception, therefore you need to wrap them in a `try/
218217
Below an example:
219218

220219
```cpp
221-
// Previous service init code...
222-
223-
std::string final_output = "Empty Result!";
224-
try {
225-
::graphql::peg::ast query_ast = ::graphql::peg::parseString(query_input);
226-
final_output =
227-
::graphql::response::toJSON(service->resolve({query_ast, ""}).get());
228-
} catch (std::exception &e) {
229-
std::cerr << e.what() << std::endl;
230-
}
231-
return std::string(final_output);
220+
// Previous service init code...
221+
222+
std::string final_output = "Empty Result!";
223+
try {
224+
::graphql::peg::ast query_ast = ::graphql::peg::parseString(query_input);
225+
final_output =
226+
::graphql::response::toJSON(service->resolve({query_ast, ""}).get());
227+
} catch (std::exception &e) {
228+
std::cerr << e.what() << std::endl;
229+
}
230+
return std::string(final_output);
232231
```
233232

234233
In this case `final_output` will be the final `GraphQL` response which can be given to a client.

0 commit comments

Comments
 (0)