{"id":13499473,"url":"https://github.com/caffeinetv/CaffQL","last_synced_at":"2025-03-29T05:31:28.142Z","repository":{"id":40329692,"uuid":"186683973","full_name":"caffeinetv/CaffQL","owner":"caffeinetv","description":"GraphQL c++ client code generator","archived":false,"fork":false,"pushed_at":"2020-03-31T09:27:42.000Z","size":279,"stargazers_count":28,"open_issues_count":3,"forks_count":5,"subscribers_count":32,"default_branch":"master","last_synced_at":"2024-05-06T22:34:21.824Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/caffeinetv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-14T19:08:19.000Z","updated_at":"2023-12-21T03:00:03.000Z","dependencies_parsed_at":"2022-08-18T00:55:54.364Z","dependency_job_id":null,"html_url":"https://github.com/caffeinetv/CaffQL","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caffeinetv%2FCaffQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caffeinetv%2FCaffQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caffeinetv%2FCaffQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caffeinetv%2FCaffQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caffeinetv","download_url":"https://codeload.github.com/caffeinetv/CaffQL/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213424231,"owners_count":15585270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T22:00:33.457Z","updated_at":"2024-10-31T18:30:30.591Z","avatar_url":"https://github.com/caffeinetv.png","language":"C++","readme":"# CaffQL\n\n`caffql` generates c++ types and GraphQL request and response serialization logic from a GraphQL json schema file.\n\n## Usage\n\n### Command line options\n```bash\n-s, --schema arg     input json schema file\n-o, --output arg     output generated header file\n-n, --namespace arg  generated namespace (default: caffql)\n-a, --absl           use absl optional and variant instead of std\n-h, --help           help\n```\n\n### Example\n```bash\ncaffql \\\n    --schema mygraphqlschema.json \\\n    --output GeneratedCode.hpp\n```\n\n### Obtaining a GraphQL json schema file\nMake an [introspection query](IntrospectionQuery.graphql) to your graphql endpoint and use the resulting json response as the `schema` parameter to `caffql`.\n\n## Generated Code\n`caffql` generates a c++ header file with types necessary to perform queries.\n### Requirements\n* c++17 for `std::optional` and `std::variant`  \n  **or** c++11 and [Abseil](https://abseil.io/) for `absl::optional` and `absl::variant`\n* [nlohmann/json](https://github.com/nlohmann/json) for request and response serialization\n\n### Operations\n`caffql` will generate request and response functions for each field of the input schema's operation types (`query`, `subscription`, and `mutation`). Currently only a single field can be queried at once. \n\nAll subfields and nested types of that field will be included in the query, i.e. there is no way to query a subset of a model. The benefits to this approach are that you don't have to handwrite any queries and the generated request and response functions are kept simple, while the drawback is that you can't omit any unwanted data.\n\n### Types\n\n| GraphQL Type    | Generated C++ Type                                         |\n|-----------------|------------------------------------------------------------|\n| Int             | int32_t                                                    |\n| Float           | double                                                     |\n| String          | std::string                                                |\n| ID              | Id (std::string typealias)                                 |\n| Boolean         | bool                                                       |\n| Enum            | enum class                                                 |\n| Object          | struct                                                     |\n| Interface       | struct containing std::variant of possible implementations |\n| Union           | variant of possible types                             |\n| InputObject     | struct                                                     |\n| List            | std::vector                                                |\n| Nullable fields | optional                                              |\n\n#### Type considerations and forwards compatibility\n##### Enums\nFor forwards compatibility, a special `Unknown` case is generated. Enum values that the client is unaware of will be deserialized to the `Unknown` case.\n\n##### Interfaces\nInterfaces are generated as `struct`s with an `implementation` member that is a `std::variant` of the possible implementations of the interface. For each field of the interface, a member function is generated that visits the `implementation` and returns the field.\n\nAn alternative approach would be to use a pure abstract class for the interface and have the implementations inherit from it. However, that approach prevents using the interface type as a simple value type (which would require implementing something like a polymorphic value-copying smart pointer).\n\nFor forwards compatibility, a special `Unknown\u003cInterfaceName\u003e` type is generated that contains the fields of the interface. Interface implementations that the client is unaware of will deserialize to the `Unknown\u003cInterfaceName\u003e` type.\n\n##### Unions\nFor forwards compatibility, the generated `std::variant` adds `std::monostate` as a possible type to handle unknown types that the client is unaware of.\n\n\n\n","funding_links":[],"categories":["Libraries","Implementations"],"sub_categories":["C/C++ Libraries","C/C++"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaffeinetv%2FCaffQL","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaffeinetv%2FCaffQL","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaffeinetv%2FCaffQL/lists"}