You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You end up with the generated member for DocumentFields
std::optional<bool> default {};
Which is a no-go due to the default keyword.
While in our case we have the opportunity to change this schema - obviously thats not available to everyone.
I've seen other libs work around the keywords issue by renaming keys to be default_ or similar - boost::hana does this for default_ and case_
I've only dug into the library just now so unsure how the generator works under the hood - this might be a hard one to work around in the generator code.
The text was updated successfully, but these errors were encountered:
Good catch. There is a mechanism for safe C++ names in the generator, it handles the leading __ or _ followed by a capital letter: SchemaLoader::getSafeCppName.
Once it makes a replacement, it stores the replacement in a static map called safeNames, so it doesn't redo the regex_replace. In retrospect, it might make sense to store the misses for regex_search as well, since an unordered_map lookup should be much faster, and the number of unique names in the GraphQL schema is not that large compared to the parsed AST.
One simple way to handle additional keywords would be pre-fill the safeNames map with entries for all known C++ keywords and their replacements if they appear in the GraphQL schema.
For a schema file
You end up with the generated member for
DocumentFields
Which is a no-go due to the
default
keyword.While in our case we have the opportunity to change this schema - obviously thats not available to everyone.
I've seen other libs work around the keywords issue by renaming keys to be
default_
or similar -boost::hana
does this fordefault_
andcase_
I've only dug into the library just now so unsure how the generator works under the hood - this might be a hard one to work around in the generator code.
The text was updated successfully, but these errors were encountered: