diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..7407e1a Binary files /dev/null and b/.DS_Store differ diff --git a/cpp-golang-ffi/.DS_Store b/cpp-golang-ffi/.DS_Store new file mode 100644 index 0000000..ef6414f Binary files /dev/null and b/cpp-golang-ffi/.DS_Store differ diff --git a/CMakeLists.txt b/cpp-golang-ffi/CMakeLists.txt similarity index 100% rename from CMakeLists.txt rename to cpp-golang-ffi/CMakeLists.txt diff --git a/README.md b/cpp-golang-ffi/README.md similarity index 100% rename from README.md rename to cpp-golang-ffi/README.md diff --git a/compile_commands.json b/cpp-golang-ffi/compile_commands.json similarity index 100% rename from compile_commands.json rename to cpp-golang-ffi/compile_commands.json diff --git a/external/cxxopts/cxxopts.hpp b/cpp-golang-ffi/external/cxxopts/cxxopts.hpp similarity index 100% rename from external/cxxopts/cxxopts.hpp rename to cpp-golang-ffi/external/cxxopts/cxxopts.hpp diff --git a/generate.sh b/cpp-golang-ffi/generate.sh similarity index 100% rename from generate.sh rename to cpp-golang-ffi/generate.sh diff --git a/cpp-golang-ffi/go/.DS_Store b/cpp-golang-ffi/go/.DS_Store new file mode 100644 index 0000000..87db89b Binary files /dev/null and b/cpp-golang-ffi/go/.DS_Store differ diff --git a/go/build.sh b/cpp-golang-ffi/go/build.sh similarity index 100% rename from go/build.sh rename to cpp-golang-ffi/go/build.sh diff --git a/go/cmd/main.go b/cpp-golang-ffi/go/cmd/main.go similarity index 100% rename from go/cmd/main.go rename to cpp-golang-ffi/go/cmd/main.go diff --git a/go/generated.go b/cpp-golang-ffi/go/generated.go similarity index 100% rename from go/generated.go rename to cpp-golang-ffi/go/generated.go diff --git a/go/go.mod b/cpp-golang-ffi/go/go.mod similarity index 100% rename from go/go.mod rename to cpp-golang-ffi/go/go.mod diff --git a/go/go.sum b/cpp-golang-ffi/go/go.sum similarity index 100% rename from go/go.sum rename to cpp-golang-ffi/go/go.sum diff --git a/go/internal/graph/generated.go b/cpp-golang-ffi/go/internal/graph/generated.go similarity index 100% rename from go/internal/graph/generated.go rename to cpp-golang-ffi/go/internal/graph/generated.go diff --git a/go/internal/graph/genqlient.graphql b/cpp-golang-ffi/go/internal/graph/genqlient.graphql similarity index 100% rename from go/internal/graph/genqlient.graphql rename to cpp-golang-ffi/go/internal/graph/genqlient.graphql diff --git a/go/internal/graph/genqlient.yaml b/cpp-golang-ffi/go/internal/graph/genqlient.yaml similarity index 100% rename from go/internal/graph/genqlient.yaml rename to cpp-golang-ffi/go/internal/graph/genqlient.yaml diff --git a/go/internal/graph/schema.graphql b/cpp-golang-ffi/go/internal/graph/schema.graphql similarity index 100% rename from go/internal/graph/schema.graphql rename to cpp-golang-ffi/go/internal/graph/schema.graphql diff --git a/go/libgraphql.dylib b/cpp-golang-ffi/go/libgraphql.dylib similarity index 100% rename from go/libgraphql.dylib rename to cpp-golang-ffi/go/libgraphql.dylib diff --git a/go/libgraphql.h b/cpp-golang-ffi/go/libgraphql.h similarity index 100% rename from go/libgraphql.h rename to cpp-golang-ffi/go/libgraphql.h diff --git a/run.sh b/cpp-golang-ffi/run.sh similarity index 100% rename from run.sh rename to cpp-golang-ffi/run.sh diff --git a/src/generated/ClientClient.cpp b/cpp-golang-ffi/src/generated/ClientClient.cpp similarity index 100% rename from src/generated/ClientClient.cpp rename to cpp-golang-ffi/src/generated/ClientClient.cpp diff --git a/src/generated/ClientClient.h b/cpp-golang-ffi/src/generated/ClientClient.h similarity index 100% rename from src/generated/ClientClient.h rename to cpp-golang-ffi/src/generated/ClientClient.h diff --git a/src/main.cpp b/cpp-golang-ffi/src/main.cpp similarity index 100% rename from src/main.cpp rename to cpp-golang-ffi/src/main.cpp diff --git a/src/query.graphql b/cpp-golang-ffi/src/query.graphql similarity index 100% rename from src/query.graphql rename to cpp-golang-ffi/src/query.graphql diff --git a/src/schema.graphqls b/cpp-golang-ffi/src/schema.graphqls similarity index 100% rename from src/schema.graphqls rename to cpp-golang-ffi/src/schema.graphqls diff --git a/external/cppgraphqlgen b/external/cppgraphqlgen deleted file mode 160000 index 0df2b32..0000000 --- a/external/cppgraphqlgen +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0df2b32d94402ecc090bf55b9d7cf7ab2cf93245 diff --git a/qt-cli/.cache/clangd/index/main.cpp.91EA9E614D588597.idx b/qt-cli/.cache/clangd/index/main.cpp.91EA9E614D588597.idx new file mode 100644 index 0000000..b9538f4 Binary files /dev/null and b/qt-cli/.cache/clangd/index/main.cpp.91EA9E614D588597.idx differ diff --git a/qt-cli/.clang-format b/qt-cli/.clang-format new file mode 100644 index 0000000..d40b07c --- /dev/null +++ b/qt-cli/.clang-format @@ -0,0 +1,4 @@ +BasedOnStyle: Microsoft +TabWidth: 2 +IndentWidth: 2 + diff --git a/qt-cli/.gitignore b/qt-cli/.gitignore new file mode 100644 index 0000000..aa3808c --- /dev/null +++ b/qt-cli/.gitignore @@ -0,0 +1,82 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* +*.qbs.user* +CMakeLists.txt.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + +# Directories with generated files +.moc/ +.obj/ +.pch/ +.rcc/ +.uic/ +/build*/ diff --git a/qt-cli/CMakeLists.txt b/qt-cli/CMakeLists.txt new file mode 100644 index 0000000..6521506 --- /dev/null +++ b/qt-cli/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.16) + +project(qt-cli LANGUAGES CXX) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Network) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Network) + +add_executable(qt-cli + main.cpp +) +target_link_libraries(qt-cli Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Network) + +include(GNUInstallDirs) +install(TARGETS qt-cli + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/qt-cli/compile_commands.json b/qt-cli/compile_commands.json new file mode 120000 index 0000000..8eabf03 --- /dev/null +++ b/qt-cli/compile_commands.json @@ -0,0 +1 @@ +build/Qt_6_8_2_for_macOS-Debug/compile_commands.json \ No newline at end of file diff --git a/qt-cli/main.cpp b/qt-cli/main.cpp new file mode 100644 index 0000000..647770f --- /dev/null +++ b/qt-cli/main.cpp @@ -0,0 +1,100 @@ +#include +#include +#include +#include +#include +#include + +struct WaitlistEntry +{ + QString firstName; + QString lastName; + QString email; +}; + +QVector parseGraphQLResponse(const QByteArray &responseData) +{ + QVector waitlist; + QJsonDocument doc = QJsonDocument::fromJson(responseData); + if (!doc.isObject()) + return waitlist; + + QJsonObject obj = doc.object(); + QJsonArray entries = obj["data"].toObject()["getWaitlist"].toArray(); + + for (const QJsonValue &value : entries) + { + QJsonObject entryObj = value.toObject(); + WaitlistEntry entry{entryObj["firstName"].toString(), entryObj["lastName"].toString(), + entryObj["email"].toString()}; + waitlist.append(entry); + } + return waitlist; +} + +void sendGraphQLQuery(QNetworkAccessManager &manager) +{ + QUrl url("https://helios.dev.flowy.live/query"); + QNetworkRequest request(url); + request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); + request.setRawHeader("Authorization", "talksik"); + + // Define GraphQL query + QJsonObject json; + json["query"] = R"( + query { + getWaitlist { + firstName + lastName + email + } + } + )"; + + // Convert to JSON and send request + QNetworkReply *reply = manager.post(request, QJsonDocument(json).toJson()); + + // Handle response asynchronously + QObject::connect(reply, &QNetworkReply::finished, [reply]() { + if (reply->error() == QNetworkReply::NoError) + { + auto response = reply->readAll(); + + auto parsedEntries = parseGraphQLResponse(response); + + for (const auto &entry : parsedEntries) + { + qDebug() << "Entry: " << entry.email << Qt::endl; + } + } + else + { + qDebug() << "Error:" << reply->errorString(); + } + reply->deleteLater(); + + QCoreApplication::quit(); + }); +} + +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + + // Set up code that uses the Qt event loop here. + // Call a.quit() or a.exit() to quit the application. + // A not very useful example would be including + // #include + // near the top of the file and calling + // QTimer::singleShot(5000, &a, &QCoreApplication::quit); + // which quits the application after 5 seconds. + + // If you do not need a running Qt event loop, remove the call + // to a.exec() or use the Non-Qt Plain C++ Application template. + qDebug() << "Sending GraphQL query..."; + QNetworkAccessManager manager; + sendGraphQLQuery(manager); + qDebug() << "Waiting for response..."; + + return a.exec(); +}