Merge branch 'master' into fix_csp
This commit is contained in:
commit
de8467f6d5
|
@ -25,7 +25,8 @@
|
|||
"azuyalabs/yasumi": "^2.4",
|
||||
"ministryofweb/php-osm-tiles": "^2.0",
|
||||
"jenstornell/tiny-html-minifier": "dev-master",
|
||||
"delight-im/db": "^1.3"
|
||||
"delight-im/db": "^1.3",
|
||||
"webonyx/graphql-php": "^14.7"
|
||||
},
|
||||
"license": "GPL-3.0-or-later",
|
||||
"authors": [
|
||||
|
|
|
@ -2963,6 +2963,72 @@
|
|||
"source": "https://github.com/getopt-php/getopt-php/tree/v3.4.0"
|
||||
},
|
||||
"time": "2020-07-14T06:09:04+00:00"
|
||||
},
|
||||
{
|
||||
"name": "webonyx/graphql-php",
|
||||
"version": "v14.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/webonyx/graphql-php.git",
|
||||
"reference": "6b0ba9a4688b2ef74ea4d52b27477dd80fa67f31"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/webonyx/graphql-php/zipball/6b0ba9a4688b2ef74ea4d52b27477dd80fa67f31",
|
||||
"reference": "6b0ba9a4688b2ef74ea4d52b27477dd80fa67f31",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"php": "^7.1||^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"amphp/amp": "^2.3",
|
||||
"doctrine/coding-standard": "^6.0",
|
||||
"nyholm/psr7": "^1.2",
|
||||
"phpbench/phpbench": "^0.16.10",
|
||||
"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.7.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://opencollective.com/webonyx-graphql-php",
|
||||
"type": "open_collective"
|
||||
}
|
||||
],
|
||||
"time": "2021-05-17T19:21:04+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
|
|
|
@ -0,0 +1,199 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// Test this using following command
|
||||
// php -S localhost:8080 ./graphql.php &
|
||||
// curl http://localhost:8080 -d '{"query": "query { echo(message: \"Hello World\") }" }'
|
||||
// curl http://localhost:8080 -d '{"query": "mutation { sum(x: 2, y: 2) }" }'
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
use GraphQL\GraphQL;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Schema;
|
||||
|
||||
$users = [[
|
||||
'email' => "email",
|
||||
'username' => "username",
|
||||
'name' => "Name",
|
||||
'available' => true,
|
||||
'chief' => true,
|
||||
'driver' => true,
|
||||
'phoneNumber' => "+11234567891",
|
||||
'services' => 0,
|
||||
'trainings' => 0,
|
||||
'availabilityMinutes' => 0,
|
||||
'verified' => true,
|
||||
'hidden' => false,
|
||||
'disabled' => false,
|
||||
],[
|
||||
'email' => "email2",
|
||||
'username' => "username2",
|
||||
'name' => "Name2",
|
||||
'available' => true,
|
||||
'chief' => true,
|
||||
'driver' => true,
|
||||
'phoneNumber' => "+11234567892",
|
||||
'services' => 0,
|
||||
'trainings' => 0,
|
||||
'availabilityMinutes' => 0,
|
||||
'verified' => true,
|
||||
'hidden' => false,
|
||||
'disabled' => false,
|
||||
]];
|
||||
|
||||
try {
|
||||
$userType = new ObjectType([
|
||||
'name' => 'User',
|
||||
'description' => 'Allerta User',
|
||||
'fields' => [
|
||||
'id' => Type::int(),
|
||||
'email' => Type::string(),
|
||||
'username' => Type::string(),
|
||||
'name' => Type::string(),
|
||||
'available' => Type::boolean(),
|
||||
'chief' => Type::boolean(),
|
||||
'driver' => Type::boolean(),
|
||||
'phoneNumber' => Type::string(), //TODO: custom type
|
||||
'services' => Type::int(),
|
||||
'trainings' => Type::int(),
|
||||
'availabilityMinutes' => Type::int(),
|
||||
'verified' => Type::boolean(),
|
||||
'hidden' => Type::boolean(),
|
||||
'disabled' => Type::boolean(),
|
||||
]
|
||||
]);
|
||||
|
||||
$queryType = new ObjectType([
|
||||
'name' => 'Query',
|
||||
'fields' => [
|
||||
'echo' => [
|
||||
'type' => Type::string(),
|
||||
'args' => [
|
||||
'message' => ['type' => Type::string()],
|
||||
],
|
||||
'resolve' => static function ($rootValue, array $args): string {
|
||||
return $rootValue['prefix'] . $args['message'];
|
||||
},
|
||||
],
|
||||
'user' => [
|
||||
'type' => $userType,
|
||||
'args' => [
|
||||
'id' => [
|
||||
'type' => Type::int(),
|
||||
]
|
||||
],
|
||||
'resolve' => function ($rootValue, array $args) {
|
||||
global $users;
|
||||
return $users[0];
|
||||
},
|
||||
],
|
||||
'Users' => [
|
||||
'type' => Type::listOf($userType),
|
||||
'args' => [
|
||||
'id' => [
|
||||
'type' => Type::int(),
|
||||
],
|
||||
'username' => [
|
||||
'type' => Type::string(),
|
||||
],
|
||||
'available' => [
|
||||
'type' => Type::boolean(),
|
||||
],
|
||||
'chief' => [
|
||||
'type' => Type::boolean(),
|
||||
],
|
||||
'driver' => [
|
||||
'type' => Type::boolean(),
|
||||
],
|
||||
'services' => [
|
||||
'type' => Type::int(),
|
||||
],
|
||||
'trainings' => [
|
||||
'type' => Type::int(),
|
||||
],
|
||||
'availabilityMinutes' => [
|
||||
'type' => Type::int(),
|
||||
],
|
||||
'verified' => [
|
||||
'type' => Type::boolean(),
|
||||
],
|
||||
'hidden' => [
|
||||
'type' => Type::boolean(),
|
||||
],
|
||||
'disabled' => [
|
||||
'type' => Type::boolean()
|
||||
]
|
||||
],
|
||||
'resolve' => function ($rootValue, array $args) {
|
||||
global $db, $user;
|
||||
$profiles = $db->select("SELECT * FROM `".DB_PREFIX."_profiles`");
|
||||
$users = $db->select("SELECT * FROM `".DB_PREFIX."_users`");
|
||||
$result = [];
|
||||
for ($i=0; $i < sizeof($profiles); $i++) {
|
||||
$result[] = [
|
||||
"id" => $users["id"],
|
||||
"email" => $profiles["email"],
|
||||
"username" => $users["username"],
|
||||
"name" => $user->nameById($users["id"]),
|
||||
"available" => $profiles["available"],
|
||||
"chief" => $profiles["chief"],
|
||||
"driver" => $profiles["driver"],
|
||||
"phoneNumber" => $profiles["phone_number"],
|
||||
"services" => $profiles["services"],
|
||||
"trainings" => $profiles["trainings"],
|
||||
"availabilityMinutes" => $profiles["availabilityMinutes"],
|
||||
"verified" => $users["verified"],
|
||||
"hidden" => $profiles["hidden"],
|
||||
"disabled" => $profiles["disabled"],
|
||||
];
|
||||
}
|
||||
return $result;
|
||||
},
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
$mutationType = new ObjectType([
|
||||
'name' => 'Calc',
|
||||
'fields' => [
|
||||
'sum' => [
|
||||
'type' => Type::int(),
|
||||
'args' => [
|
||||
'x' => ['type' => Type::int()],
|
||||
'y' => ['type' => Type::int()],
|
||||
],
|
||||
'resolve' => static function ($calc, array $args): int {
|
||||
return $args['x'] + $args['y'];
|
||||
},
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
// See docs on schema options:
|
||||
// https://webonyx.github.io/graphql-php/type-system/schema/#configuration-options
|
||||
$schema = new Schema([
|
||||
'query' => $queryType,
|
||||
'mutation' => $mutationType,
|
||||
]);
|
||||
|
||||
$rawInput = file_get_contents('php://input');
|
||||
$input = json_decode($rawInput, true);
|
||||
$query = $input['query'];
|
||||
$variableValues = $input['variables'] ?? null;
|
||||
|
||||
$rootValue = ['prefix' => 'You said: '];
|
||||
$result = GraphQL::executeQuery($schema, $query, $rootValue, null, $variableValues);
|
||||
$output = $result->toArray();
|
||||
} catch (Throwable $e) {
|
||||
$output = [
|
||||
'error' => [
|
||||
'message' => $e->getMessage(),
|
||||
"object" => $e
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
header('Content-Type: application/json; charset=UTF-8');
|
||||
echo json_encode($output);
|
|
@ -48,7 +48,7 @@
|
|||
"terser-webpack-plugin": "^5.1.2",
|
||||
"time-input-polyfill": "^1.0.10",
|
||||
"toastr": "^2.1.4",
|
||||
"webpack": "^5.37.1",
|
||||
"webpack": "^5.38.1",
|
||||
"webpack-assets-manifest": "^5.0.6",
|
||||
"webpack-inject-plugin": "^1.5.5",
|
||||
"webpack-merge": "^5.7.3"
|
||||
|
@ -5588,9 +5588,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/watchpack": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.1.1.tgz",
|
||||
"integrity": "sha512-Oo7LXCmc1eE1AjyuSBmtC3+Wy4HcV8PxWh2kP6fOl8yTlNS7r0K9l1ao2lrrUza7V39Y3D/BbJgY8VeSlc5JKw==",
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.2.0.tgz",
|
||||
"integrity": "sha512-up4YAn/XHgZHIxFBVCdlMiWDj6WaLKpwVeGQk2I5thdYxF/KmF0aaz6TfJZ/hfl1h/XlcDr7k1KH7ThDagpFaA==",
|
||||
"dependencies": {
|
||||
"glob-to-regexp": "^0.4.1",
|
||||
"graceful-fs": "^4.1.2"
|
||||
|
@ -5600,9 +5600,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/webpack": {
|
||||
"version": "5.37.1",
|
||||
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.37.1.tgz",
|
||||
"integrity": "sha512-btZjGy/hSjCAAVHw+cKG+L0M+rstlyxbO2C+BOTaQ5/XAnxkDrP5sVbqWhXgo4pL3X2dcOib6rqCP20Zr9PLow==",
|
||||
"version": "5.38.1",
|
||||
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.38.1.tgz",
|
||||
"integrity": "sha512-OqRmYD1OJbHZph6RUMD93GcCZy4Z4wC0ele4FXyYF0J6AxO1vOSuIlU1hkS/lDlR9CDYBz64MZRmdbdnFFoT2g==",
|
||||
"dependencies": {
|
||||
"@types/eslint-scope": "^3.7.0",
|
||||
"@types/estree": "^0.0.47",
|
||||
|
@ -5614,7 +5614,7 @@
|
|||
"chrome-trace-event": "^1.0.2",
|
||||
"enhanced-resolve": "^5.8.0",
|
||||
"es-module-lexer": "^0.4.0",
|
||||
"eslint-scope": "^5.1.1",
|
||||
"eslint-scope": "5.1.1",
|
||||
"events": "^3.2.0",
|
||||
"glob-to-regexp": "^0.4.1",
|
||||
"graceful-fs": "^4.2.4",
|
||||
|
@ -5625,8 +5625,8 @@
|
|||
"schema-utils": "^3.0.0",
|
||||
"tapable": "^2.1.1",
|
||||
"terser-webpack-plugin": "^5.1.1",
|
||||
"watchpack": "^2.0.0",
|
||||
"webpack-sources": "^2.1.1"
|
||||
"watchpack": "^2.2.0",
|
||||
"webpack-sources": "^2.3.0"
|
||||
},
|
||||
"bin": {
|
||||
"webpack": "bin/webpack.js"
|
||||
|
@ -5976,6 +5976,26 @@
|
|||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/webpack-sources": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-2.3.0.tgz",
|
||||
"integrity": "sha512-WyOdtwSvOML1kbgtXbTDnEW0jkJ7hZr/bDByIwszhWd/4XX1A3XMkrbFMsuH4+/MfLlZCUzlAdg4r7jaGKEIgQ==",
|
||||
"dependencies": {
|
||||
"source-list-map": "^2.0.1",
|
||||
"source-map": "^0.6.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/webpack-sources/node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/webpack/node_modules/acorn": {
|
||||
"version": "8.2.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.2.1.tgz",
|
||||
|
@ -6004,26 +6024,6 @@
|
|||
"url": "https://opencollective.com/webpack"
|
||||
}
|
||||
},
|
||||
"node_modules/webpack/node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/webpack/node_modules/webpack-sources": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-2.2.0.tgz",
|
||||
"integrity": "sha512-bQsA24JLwcnWGArOKUxYKhX3Mz/nK1Xf6hxullKERyktjNMC4x8koOeaDNTA2fEJ09BdWLbM/iTW0ithREUP0w==",
|
||||
"dependencies": {
|
||||
"source-list-map": "^2.0.1",
|
||||
"source-map": "^0.6.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
|
@ -10385,18 +10385,18 @@
|
|||
"dev": true
|
||||
},
|
||||
"watchpack": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.1.1.tgz",
|
||||
"integrity": "sha512-Oo7LXCmc1eE1AjyuSBmtC3+Wy4HcV8PxWh2kP6fOl8yTlNS7r0K9l1ao2lrrUza7V39Y3D/BbJgY8VeSlc5JKw==",
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.2.0.tgz",
|
||||
"integrity": "sha512-up4YAn/XHgZHIxFBVCdlMiWDj6WaLKpwVeGQk2I5thdYxF/KmF0aaz6TfJZ/hfl1h/XlcDr7k1KH7ThDagpFaA==",
|
||||
"requires": {
|
||||
"glob-to-regexp": "^0.4.1",
|
||||
"graceful-fs": "^4.1.2"
|
||||
}
|
||||
},
|
||||
"webpack": {
|
||||
"version": "5.37.1",
|
||||
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.37.1.tgz",
|
||||
"integrity": "sha512-btZjGy/hSjCAAVHw+cKG+L0M+rstlyxbO2C+BOTaQ5/XAnxkDrP5sVbqWhXgo4pL3X2dcOib6rqCP20Zr9PLow==",
|
||||
"version": "5.38.1",
|
||||
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.38.1.tgz",
|
||||
"integrity": "sha512-OqRmYD1OJbHZph6RUMD93GcCZy4Z4wC0ele4FXyYF0J6AxO1vOSuIlU1hkS/lDlR9CDYBz64MZRmdbdnFFoT2g==",
|
||||
"requires": {
|
||||
"@types/eslint-scope": "^3.7.0",
|
||||
"@types/estree": "^0.0.47",
|
||||
|
@ -10408,7 +10408,7 @@
|
|||
"chrome-trace-event": "^1.0.2",
|
||||
"enhanced-resolve": "^5.8.0",
|
||||
"es-module-lexer": "^0.4.0",
|
||||
"eslint-scope": "^5.1.1",
|
||||
"eslint-scope": "5.1.1",
|
||||
"events": "^3.2.0",
|
||||
"glob-to-regexp": "^0.4.1",
|
||||
"graceful-fs": "^4.2.4",
|
||||
|
@ -10419,8 +10419,8 @@
|
|||
"schema-utils": "^3.0.0",
|
||||
"tapable": "^2.1.1",
|
||||
"terser-webpack-plugin": "^5.1.1",
|
||||
"watchpack": "^2.0.0",
|
||||
"webpack-sources": "^2.1.1"
|
||||
"watchpack": "^2.2.0",
|
||||
"webpack-sources": "^2.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"acorn": {
|
||||
|
@ -10437,20 +10437,6 @@
|
|||
"ajv": "^6.12.5",
|
||||
"ajv-keywords": "^3.5.2"
|
||||
}
|
||||
},
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
|
||||
},
|
||||
"webpack-sources": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-2.2.0.tgz",
|
||||
"integrity": "sha512-bQsA24JLwcnWGArOKUxYKhX3Mz/nK1Xf6hxullKERyktjNMC4x8koOeaDNTA2fEJ09BdWLbM/iTW0ithREUP0w==",
|
||||
"requires": {
|
||||
"source-list-map": "^2.0.1",
|
||||
"source-map": "^0.6.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -10680,6 +10666,22 @@
|
|||
"wildcard": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"webpack-sources": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-2.3.0.tgz",
|
||||
"integrity": "sha512-WyOdtwSvOML1kbgtXbTDnEW0jkJ7hZr/bDByIwszhWd/4XX1A3XMkrbFMsuH4+/MfLlZCUzlAdg4r7jaGKEIgQ==",
|
||||
"requires": {
|
||||
"source-list-map": "^2.0.1",
|
||||
"source-map": "^0.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
"terser-webpack-plugin": "^5.1.2",
|
||||
"time-input-polyfill": "^1.0.10",
|
||||
"toastr": "^2.1.4",
|
||||
"webpack": "^5.37.1",
|
||||
"webpack": "^5.38.1",
|
||||
"webpack-assets-manifest": "^5.0.6",
|
||||
"webpack-inject-plugin": "^1.5.5",
|
||||
"webpack-merge": "^5.7.3"
|
||||
|
|
Loading…
Reference in New Issue