Compare commits

...

13 Commits

Author SHA1 Message Date
Kilian 172128b37b Relations 2021-08-16 11:34:24 +02:00
Kilian 8bb522ec33 Create Exams 2021-08-16 10:36:55 +02:00
Kilian f32d3a4877 MID based exams 2021-08-15 23:24:15 +02:00
Kilian 0fe449538e Grouping issues 2021-08-15 23:06:15 +02:00
Kilian c797cb9f24 Basic schooling GQL 2021-08-15 19:05:54 +02:00
Kilian e884b0e97d Unecrypted Cookie 2021-08-15 13:46:06 +02:00
Kilian 9b153dacd8 Controller Permission 2021-08-14 21:44:41 +02:00
Kilian fdf7e89afe Member FK 2021-08-14 18:28:24 +02:00
Kilian 7baa903f7a Namespace Permission 2021-08-14 14:18:31 +02:00
Kilian 3e0ba5f209 Dynamic host 2021-08-14 13:15:45 +02:00
Kilian a5598130db remove require 2021-08-04 19:51:38 +02:00
Kilian e6ceea1b1b Unused use removed 2021-08-04 19:14:52 +02:00
Your Name 064e8a8054 Formating .htm removed 2021-08-04 12:34:53 +02:00
20 changed files with 220 additions and 76 deletions
-24
View File
@@ -1,24 +0,0 @@
<?php namespace GermanAirlinesVa\Graphql;
use Closure;
class Authentication
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($request->input('gql_session') === 'SUPER_SECRET_TOKEN') {
return 'false';
} else {
return 'true';
}
return $next($request);
}
}
+3 -2
View File
@@ -5,6 +5,7 @@ use System\Classes\PluginBase;
use App; use App;
use Config; use Config;
use Illuminate\Database\DatabaseManager; use Illuminate\Database\DatabaseManager;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Foundation\AliasLoader; use Illuminate\Foundation\AliasLoader;
use GermanAirlinesVa\Graphql\Classes\GraphqlServiceProvider; use GermanAirlinesVa\Graphql\Classes\GraphqlServiceProvider;
use Nuwave\Lighthouse\Subscriptions\SubscriptionServiceProvider; use Nuwave\Lighthouse\Subscriptions\SubscriptionServiceProvider;
@@ -43,13 +44,13 @@ class Plugin extends PluginBase
$this->app->singleton(DatabaseManager::class, function ($app) { $this->app->singleton(DatabaseManager::class, function ($app) {
return $app->make('db'); return $app->make('db');
}); });
\Illuminate\Support\Facades\Broadcast::routes([ Broadcast::routes([
'prefix' => '', 'prefix' => '',
'middleware' => 'GermanAirlinesVA\\Graphql\\Classes\\Authentication', 'middleware' => 'GermanAirlinesVA\\Graphql\\Classes\\Authentication',
]); ]);
require 'channels/channels.php';
Config::set('database.connections.germanairlinesva_graphql', Config::get('germanairlinesva.graphql::connection')); Config::set('database.connections.germanairlinesva_graphql', Config::get('germanairlinesva.graphql::connection'));
Config::push('system.unencrypt_cookies', 'graphql-session-id');
} }
public function bootPackages() public function bootPackages()
+1 -1
View File
@@ -2,4 +2,4 @@
## GraphQLKeys ## GraphQLKeys
- **TODO** BelongsTo Member (External DB) - BelongsTo Member (External DB, creation in Social Plugin)
+1 -1
View File
@@ -32920,7 +32920,7 @@ var _validUrl = __webpack_require__(429);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var options = { method: 'post', headers: { 'Content-Type': 'application/json' } }; var options = { method: 'post', headers: { 'Content-Type': 'application/json' } };
var endpoint = 'http://localhost/graphql/'; // Initial var endpoint = 'http://' + window.location.host + '/graphql/'; // Initial
var defaultQuery = '\n# Welcome to GraphiQL\n#\n# GraphiQL is an in-browser tool for writing, validating, and\n# testing GraphQL queries.\n#\n# Type queries into this side of the screen, and you will see intelligent\n# typeaheads aware of the current GraphQL type schema and live syntax and\n# validation errors highlighted within the text.\n#\n# GraphQL queries typically start with a "{" character. Lines that starts\n# with a # are ignored.\n#\n# An example GraphQL query might look like:\n#\n# {\n# field(arg: "value") {\n# subField\n# }\n# }\n#\n# Keyboard shortcuts:\n#\n# Run Query: Ctrl-Enter (or press the play button above)\n#\n# Auto Complete: Ctrl-Space (or just start typing)\n#\n# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #\n# Default endpoint is an instance of https://www.graph.cool/\n# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #\n\nquery {\n countries {\n name\n }\n}\n'; var defaultQuery = '\n# Welcome to GraphiQL\n#\n# GraphiQL is an in-browser tool for writing, validating, and\n# testing GraphQL queries.\n#\n# Type queries into this side of the screen, and you will see intelligent\n# typeaheads aware of the current GraphQL type schema and live syntax and\n# validation errors highlighted within the text.\n#\n# GraphQL queries typically start with a "{" character. Lines that starts\n# with a # are ignored.\n#\n# An example GraphQL query might look like:\n#\n# {\n# field(arg: "value") {\n# subField\n# }\n# }\n#\n# Keyboard shortcuts:\n#\n# Run Query: Ctrl-Enter (or press the play button above)\n#\n# Auto Complete: Ctrl-Space (or just start typing)\n#\n# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #\n# Default endpoint is an instance of https://www.graph.cool/\n# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #\n\nquery {\n countries {\n name\n }\n}\n';
Binary file not shown.
-18
View File
@@ -1,18 +0,0 @@
<?php
use Illuminate\Support\Facades\Broadcast;
/*
|--------------------------------------------------------------------------
| Broadcast Channels
|--------------------------------------------------------------------------
|
| Here you may register all of the event broadcasting channels that your
| application supports. The given channel authorization callbacks are
| used to check if an authenticated user can listen to the channel.
|
*/
Broadcast::channel('lighthouse-*', function ($user) {
return true;
});
+2 -1
View File
@@ -1,7 +1,6 @@
<?php namespace GermanAirlinesVa\Graphql\Controllers; <?php namespace GermanAirlinesVa\Graphql\Controllers;
use Backend\Classes\Controller; use Backend\Classes\Controller;
use BackendMenu;
class GraphqlKey extends Controller class GraphqlKey extends Controller
{ {
@@ -9,6 +8,8 @@ class GraphqlKey extends Controller
public $listConfig = 'config_list.yaml'; public $listConfig = 'config_list.yaml';
public $requiredPermissions = ['germanairlinesva.graphql.master'];
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
+2 -1
View File
@@ -1,7 +1,6 @@
<?php namespace GermanAirlinesVa\Graphql\Controllers; <?php namespace GermanAirlinesVa\Graphql\Controllers;
use Backend\Classes\Controller; use Backend\Classes\Controller;
use BackendMenu;
class Playground extends Controller class Playground extends Controller
{ {
@@ -10,6 +9,8 @@ class Playground extends Controller
parent::__construct(); parent::__construct();
} }
public $requiredPermissions = ['germanairlinesva.graphql.master'];
public function index() public function index()
{ {
$this->pageTitle = 'germanairlinesva.graphql::lang.menu.playground'; $this->pageTitle = 'germanairlinesva.graphql::lang.menu.playground';
+1
View File
@@ -1 +1,2 @@
<div id="mount"></div>
<script type="text/javascript" src="/plugins/germanairlinesva/graphql/assets/js/graphiql.js"></script> <script type="text/javascript" src="/plugins/germanairlinesva/graphql/assets/js/graphiql.js"></script>
+19 -4
View File
@@ -1,4 +1,4 @@
title = "CMS" == ==
<?php <?php
use Cms\Classes\Theme; use Cms\Classes\Theme;
use Cms\Classes\Content; use Cms\Classes\Content;
@@ -11,6 +11,21 @@ function resolveCmsContent($root, $args) {
return Content::loadCached($theme, $args['name']); return Content::loadCached($theme, $args['name']);
} }
?> ?>
== # Content extend type Query { cmsContent(name: String!): CmsContent! } type CmsContent { fileName: String! content: ==
String markup: String parsedMarkup: String } # CMS-wide types # Backend\Models\User type BackendUser { id: ID! } # Content
#System\Models\File type SystemFile { id: ID path: String title: String description: String } extend type Query {
cmsContent(name: String!): CmsContent!
}
type CmsContent {
fileName: String!
content: String
markup: String
parsedMarkup: String
}
# CMS-wide types
# Backend\Models\User
type BackendUser { id: ID! }
#System\Models\File
type SystemFile { id: ID path: String title: String description: String }
+27 -8
View File
@@ -1,8 +1,27 @@
title = "Fleet" == == # Content extend type Query { aircraft: [Aircraft] @all(model: ==
"GermanAirlinesVa\\Fleet\\Models\\Aircraft") aircraftType: [AircraftType] @all(model: ==
"GermanAirlinesVa\\Fleet\\Models\\AircraftType") } extend type Subscription { aircraftAdded: Aircraft # Content
@subscription(class: "GermanAirlinesVa\\Fleet\\Classes\\AircraftAdded") } extend type Mutation { addAircraft( extend type Query {
aircraft_type_id: ID!, home_airport_id: ID!, name: String!, registration: String! ): Aircraft @create(model: aircraft: [Aircraft] @all(model: "GermanAirlinesVa\\Fleet\\Models\\Aircraft")
"GermanAirlinesVa\\Fleet\\Models\\Aircraft") @broadcast(subscription: "aircraftAdded") } type Aircraft { id: ID! aircraftType: [AircraftType] @all(model: "GermanAirlinesVa\\Fleet\\Models\\AircraftType")
aircraft_type_id: ID! home_airport_id: ID! name: String! registration: String! } type AircraftType { type: String! }
aircrafts: [Aircraft] @hasMany } extend type Subscription {
aircraftAdded: Aircraft @subscription(class: "GermanAirlinesVa\\Fleet\\Classes\\AircraftAdded")
}
extend type Mutation {
addAircraft(aircraft_type_id: ID!, home_airport_id: ID!, name: String!, registration: String! ): Aircraft
@create(model:"GermanAirlinesVa\\Fleet\\Models\\Aircraft")
@broadcast(subscription: "aircraftAdded")
}
type Aircraft {
id: ID!
aircraft_type_id: ID!
home_airport_id: ID!
name: String!
registration: String!
}
type AircraftType {
type: String!
aircrafts: [Aircraft] @hasMany
}
+150
View File
@@ -0,0 +1,150 @@
==
<?php
function resolveExamMemberRanks($root, $args) {
$exams = \GermanAirlinesVa\Schooling\Models\ExamMemberRank::where('member_id', $args['memberID'])->get();
foreach($exams as $exam) {
$exam->load([
'exam_questions' => function ($query) {
$query->groupBy('id');
}
]);
}
return $exams;
}
function resolveExamTyperatings($root, $args) {
$exams = \GermanAirlinesVa\Schooling\Models\ExamTyperating::where('member_id', $args['memberID'])->get();
foreach($exams as $exam) {
$exam->load([
'exam_questions' => function ($query) {
$query->groupBy('id');
}
]);
}
return $exams;
}
function resolveTyperatings() {
$typeratings = GermanAirlinesVa\Schooling\Models\Typerating::all();
foreach($typeratings as $typerating) {
$typerating->load([
'exam_questions' => function($query) {
$query->groupBy('id');
}
]);
}
return $typeratings;
}
function resolveMemberRanks() {
$ranks = GermanAirlinesVa\Schooling\Models\MemberRank::all();
foreach($ranks as $rank) {
$rank->load([
'exam_questions' => function($query) {
$query->groupBy('id');
}
]);
}
return $rank;
}
function createExamMemberRank($root, $args) {
return GermanAirlinesVa\Schooling\Models\ExamMemberRank::createNew($args['memberID'], $args['memberRankID']);
}
function resolveCreateExamTyperating($root, $args) {
return GermanAirlinesVa\Schooling\Models\ExamTyperating::createNew($args['memberID'], $args['typeratingID']);
}
==
# Content
extend type Query {
memberRanks: [MemberRank]!
typeratings: [Typerating]!
examMemberRanks(memberID: ID!): [ExamMemberRank]!
examTyperatings(memberID: ID!): [ExamTyperating]!
}
extend type Mutation {
createExamMemberRank(memberID: ID!, memberRankID: ID!): ExamMemberRank!
createExamTyperating(memberID: ID!, typeratingID: ID!): ExamTyperating!
}
type MemberRank {
id: ID!
name: String!
description: String!
points: Int!
price: Int!
badge: String!
region: String!
exam_questions: [ExamMemberRankQuestion]! @hasMany
exams: [ExamMemberRank]! @hasMany
}
type Typerating {
id: ID!
name: String!
price: Int!
exam_questions: [ExamTyperatingQuestion]! @hasMany
exams: [ExamTyperating]! @hasMany
}
type ExamMemberRank {
id: ID!
member_id: ID!
member_rank: MemberRank! @belongsTo
start: DateTime!
status: ExamStatus!
exam_questions: [ExamMemberRankQuestion]! @belongsToMany
exam_answers: [ExamMemberRankAnswer]! @belongsToMany
}
type ExamTyperating {
id: ID!
member_id: ID!
typerating: Typerating! @belongsTo
start: DateTime!
status: ExamStatus!
exam_questions: [ExamTyperatingQuestion]! @belongsToMany
exam_answers: [ExamTyperatingAnswer]! @belongsToMany
}
type ExamMemberRankQuestion {
id: ID!
member_rank: MemberRank! @belongsTo
in_use: Boolean!
mandatory: Boolean!
text: String!
picture: String!
exam_answers: [ExamMemberRankAnswer]! @hasMany
exam_member_ranks: [ExamMemberRank]! @belongsToMany
}
type ExamTyperatingQuestion {
id: ID!
typerating: Typerating! @belongsTo
in_use: Boolean!
mandatory: Boolean!
text: String!
picture: String!
exam_answers: [ExamTyperatingAnswer]! @hasMany
exma_typeratings: [ExamTyperating]! @belongsToMany
}
type ExamMemberRankAnswer {
id: ID!
exam_question: ExamMemberRankQuestion! @belongsTo
text: String!
is_correct: Boolean!
exam_member_ranks: [ExamMemberRank]! @belongsToMany
}
type ExamTyperatingAnswer {
id: ID!
exam_question: ExamTyperatingQuestion! @belongsTo
text: String!
is_correct: Boolean!
exam_typeratings: [ExamTyperating]! @belongsToMany
}
enum ExamStatus {
open
pending
closed
validated
}
scalar DateTime
@scalar(class: "Nuwave\\Lighthouse\\Schema\\Types\\Scalars\\DateTime")
+4 -1
View File
@@ -1,6 +1,5 @@
<?php namespace GermanAirlinesVa\Graphql\Models; <?php namespace GermanAirlinesVa\Graphql\Models;
use Cms\Classes\Theme;
use Model; use Model;
class GraphqlKey extends Model class GraphqlKey extends Model
@@ -26,4 +25,8 @@ class GraphqlKey extends Model
'member_id' => 'required', 'member_id' => 'required',
'key' => 'required', 'key' => 'required',
]; ];
public $belongsTo = [
'member' => 'GermanAirlinesVa\Social\Models\Member',
];
} }
-1
View File
@@ -1,6 +1,5 @@
<?php namespace GermanAirlinesVa\Graphql\Models; <?php namespace GermanAirlinesVa\Graphql\Models;
use Cms\Classes\Theme;
use Model; use Model;
class Settings extends Model class Settings extends Model
+5 -3
View File
@@ -2,9 +2,11 @@ columns:
id: id:
label: id label: id
type: number type: number
member_id: member:
label: member_id label: member
type: number type: text
relation: member
valueFrom: name
valid_from: valid_from:
label: valid_from label: valid_from
type: datetime type: datetime
+1 -1
View File
@@ -11,6 +11,6 @@
}, },
"scripts": { "scripts": {
"preinstall": "git config core.hooksPath .hooks", "preinstall": "git config core.hooksPath .hooks",
"format": "prettier --write './**/*.{php,html,htm,yaml}'" "format": "prettier --write './**/*.{php,html,yaml}'"
} }
} }
+2 -2
View File
@@ -5,7 +5,7 @@ plugin:
icon: oc-icon-database icon: oc-icon-database
homepage: '' homepage: ''
permissions: permissions:
schemas: germanairlinesva.graphql.master:
tab: 'germanairlinesva.graphql::lang.permission.tab.schemas' tab: 'germanairlinesva.graphql::lang.permission.tab.schemas'
label: 'germanairlinesva.graphql::lang.permission.label.schemas' label: 'germanairlinesva.graphql::lang.permission.label.schemas'
navigation: navigation:
@@ -14,7 +14,7 @@ navigation:
url: / url: /
icon: icon-database icon: icon-database
permissions: permissions:
- schemas - germanairlinesva.graphql.master
sideMenu: sideMenu:
side-menu-item: side-menu-item:
label: 'germanairlinesva.graphql::lang.menu.playground' label: 'germanairlinesva.graphql::lang.menu.playground'
-5
View File
@@ -1,5 +0,0 @@
# Relations
## GraphQLKeys
- **TODO** BelongsTo Member (External DB)
@@ -1,6 +1,5 @@
<?php namespace GermanAirlinesVa\GraphQl\Updates; <?php namespace GermanAirlinesVa\GraphQl\Updates;
use Config;
use Schema; use Schema;
use October\Rain\Database\Updates\Migration; use October\Rain\Database\Updates\Migration;
+2 -2
View File
@@ -41,9 +41,9 @@ p-defer@^1.0.0:
resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c"
integrity sha1-n26xgvbJqozXQwBKfU+WsZaw+ww= integrity sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=
"php-parser@git+https://github.com/glayzzle/php-parser.git#e61e26102144f267ecf5e09020865a9baa6ca2f1": "php-parser@https://github.com/glayzzle/php-parser#e61e26102144f267ecf5e09020865a9baa6ca2f1":
version "3.0.2" version "3.0.2"
resolved "git+https://github.com/glayzzle/php-parser.git#e61e26102144f267ecf5e09020865a9baa6ca2f1" resolved "https://github.com/glayzzle/php-parser#e61e26102144f267ecf5e09020865a9baa6ca2f1"
prettier@^2.3.2: prettier@^2.3.2:
version "2.3.2" version "2.3.2"