diff --git a/composer.json b/composer.json
index a821251..1287a32 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,8 @@
{
"require": {
"aws/aws-sdk-php": "^3.181",
- "guzzlehttp/guzzle": "^7.0"
+ "guzzlehttp/guzzle": "^7.0",
+ "webonyx/graphql-php": "^14.11"
},
"config": {
"vendor-dir": "public/API/vendor"
diff --git a/composer.lock b/composer.lock
index 6cc263e..cea0c46 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "f47a9b8d286ca72493a7fe02f263976e",
+ "content-hash": "31a3a0321659f9c8afff63a68a9fafb6",
"packages": [
{
"name": "aws/aws-crt-php",
@@ -669,6 +669,72 @@
}
],
"time": "2021-05-27T12:26:48+00:00"
+ },
+ {
+ "name": "webonyx/graphql-php",
+ "version": "v14.11.5",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/webonyx/graphql-php.git",
+ "reference": "ffa431c0821821839370a68dab3c2597c06bf7f0"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/webonyx/graphql-php/zipball/ffa431c0821821839370a68dab3c2597c06bf7f0",
+ "reference": "ffa431c0821821839370a68dab3c2597c06bf7f0",
+ "shasum": ""
+ },
+ "require": {
+ "ext-json": "*",
+ "ext-mbstring": "*",
+ "php": "^7.1 || ^8"
+ },
+ "require-dev": {
+ "amphp/amp": "^2.3",
+ "doctrine/coding-standard": "^6.0",
+ "nyholm/psr7": "^1.2",
+ "phpbench/phpbench": "^1.2",
+ "phpstan/extension-installer": "^1.0",
+ "phpstan/phpstan": "0.12.82",
+ "phpstan/phpstan-phpunit": "0.12.18",
+ "phpstan/phpstan-strict-rules": "0.12.9",
+ "phpunit/phpunit": "^7.2 || ^8.5",
+ "psr/http-message": "^1.0",
+ "react/promise": "2.*",
+ "simpod/php-coveralls-mirror": "^3.0",
+ "squizlabs/php_codesniffer": "3.5.4"
+ },
+ "suggest": {
+ "psr/http-message": "To use standard GraphQL server",
+ "react/promise": "To leverage async resolving on React PHP platform"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "GraphQL\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "A PHP port of GraphQL reference implementation",
+ "homepage": "https://github.com/webonyx/graphql-php",
+ "keywords": [
+ "api",
+ "graphql"
+ ],
+ "support": {
+ "issues": "https://github.com/webonyx/graphql-php/issues",
+ "source": "https://github.com/webonyx/graphql-php/tree/v14.11.5"
+ },
+ "funding": [
+ {
+ "url": "https://opencollective.com/webonyx-graphql-php",
+ "type": "open_collective"
+ }
+ ],
+ "time": "2022-01-24T11:13:31+00:00"
}
],
"packages-dev": [],
@@ -679,5 +745,5 @@
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
- "plugin-api-version": "2.1.0"
+ "plugin-api-version": "2.0.0"
}
diff --git a/js/customElements/contactMailButton.js b/js/customElements/contactMailButton.js
index 646110d..d82cdbc 100644
--- a/js/customElements/contactMailButton.js
+++ b/js/customElements/contactMailButton.js
@@ -6,7 +6,15 @@ class contactMailButton extends HTMLElement {
}
async addButton() {
- let sitekey = await (await fetch("/API/config.php?name=sitekey")).text();
+ var graphql = JSON.stringify({
+ query: "query {\r\n sitekey\r\n}"
+ })
+ var requestOptions = {
+ method: 'POST',
+ body: graphql,
+ };
+
+ let sitekey = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.sitekey;
console.log(sitekey);
this.innerHTML = `E-Mail:
`;
const script = document.createElement("script");
diff --git a/public/API/config.php b/public/API/config.php
deleted file mode 100644
index 336fdbd..0000000
--- a/public/API/config.php
+++ /dev/null
@@ -1,12 +0,0 @@
- $queryType
+]);
+
+$rawInput = file_get_contents('php://input');
+$input = json_decode($rawInput, true);
+$query = $input['query'];
+$variableValues = isset($input['variables']) ? $input['variables'] : null;
+
+try {
+ $rootValue = [];
+ $result = GraphQL::executeQuery($schema, $query, $rootValue, null, $variableValues);
+ $output = $result->toArray();
+} catch (\Exception $e) {
+ $output = [
+ 'errors' => [
+ [
+ 'message' => $e->getMessage()
+ ]
+ ]
+ ];
+}
+header('Content-Type: application/json');
+echo json_encode($output);
\ No newline at end of file
diff --git a/public/API/queries/queries.php b/public/API/queries/queries.php
new file mode 100644
index 0000000..cc147c0
--- /dev/null
+++ b/public/API/queries/queries.php
@@ -0,0 +1,13 @@
+ 'Query',
+ 'fields' => [
+ 'sitekey' => [
+ 'type' => Type::string(),
+ 'resolve' => fn ($rootValue, $args) => $sitekey,
+ ],
+ ],
+]);