Skip to content
This repository has been archived by the owner on Jul 22, 2021. It is now read-only.

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFehr committed Mar 1, 2020
1 parent ece95fa commit 0173fea
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 165 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ graphql/schema.graphql.valid

node_modules/
formwidgets/graphqlschemaeditor/assets/
!formwidgets/graphqlschemaeditor/assets/.gitkeep
!formwidgets/graphqlschemaeditor/assets/.gitkeep
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "thefehr/lighthouse",
"license": "MIT",
"type": "october-plugin",
"description": "",
"require": {
Expand Down
4 changes: 2 additions & 2 deletions formwidgets/GraphQLSchemaEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public function prepareVars()
$this->vars['name'] = $this->formField->getName();
$this->vars['value'] = $this->getLoadValue();
$this->vars['model'] = $this->model;
$this->vars['webpackAssetsUrl'] = asset('plugins/thefehr/lighthouse/formwidgets/graphqlschemaeditor/assets/');
$this->vars['webpackUrl'] = asset('plugins/thefehr/lighthouse/formwidgets/graphqlschemaeditor/assets/graphqlschemaeditor.js');
$this->vars['webpackAssetsUrl'] = asset('/plugins/thefehr/lighthouse/formwidgets/graphqlschemaeditor/assets/');
$this->vars['webpackUrl'] = asset('/plugins/thefehr/lighthouse/formwidgets/graphqlschemaeditor/assets/graphqlschemaeditor.js');
}

/**
Expand Down
64 changes: 48 additions & 16 deletions formwidgets/graphqlschemaeditor/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions formwidgets/graphqlschemaeditor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dependencies": {
"babel-cli": "^6.26.0",
"babel-preset-react-app": "^3.1.2",
"graphql-editor": "^3.3.3",
"graphql-editor": "^3.3.4",
"monaco-editor": "^0.20.0",
"react": "^16.12.0",
"react-dom": "^16.12.0"
Expand All @@ -15,25 +15,25 @@
"@babel/core": "^7.8.4",
"@babel/preset-env": "^7.8.4",
"@babel/preset-react": "^7.8.3",
"@types/react": "^16.9.19",
"@types/react": "^16.9.22",
"@types/react-dom": "^16.9.5",
"babel-loader": "^8.0.6",
"css-loader": "^3.4.2",
"file-loader": "^5.0.2",
"file-loader": "^5.1.0",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.2.0",
"monaco-editor-webpack-plugin": "^1.9.0",
"source-map-loader": "^0.2.4",
"style-loader": "^1.1.3",
"ts-loader": "^6.2.1",
"ttf-loader": "^1.0.2",
"typescript": "^3.7.5",
"typescript": "^3.8.2",
"webpack": "^4.41.6",
"webpack-cli": "^3.3.11",
"worker-loader": "^2.0.0"
},
"scripts": {
"start": "webpack --watch --mode development",
"start": "webpack --mode development",
"build": "webpack"
},
"author": "",
Expand Down
31 changes: 28 additions & 3 deletions formwidgets/graphqlschemaeditor/partials/_graphqlschemaeditor.htm
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
<h2>My graphql schema editor</h2>
<div id="graphqleditor" style="height: 70vh"></div>
<input type="text" id="<?= $this->getId('input') ?>" hidden="hidden" value="<?= $value ?>">
<textarea style="height: 100%; width: 100%; display: block"
name="<?= $name ?>"
id="<?= $this->getId('input') ?>"><?= $value ?></textarea>
<script>
var graphqlEditorValueId = "<?= $this->getId('input') ?>";
var myRuntimePublicPath = "<?= $webpackAssetsUrl ?>"
var lighthouseLibrary = `
directive @all(
"""
Specify the class name of the model to use.
This is only needed when the default model detection does not work.
"""
model: String
"""
Apply scopes to the underlying query.
"""
scopes: [String!]
) on FIELD_DEFINITION
`;
</script>
<script src="<?= $webpackUrl ?>"></script>
<script src="<?= $webpackUrl ?>"></script>
<style>
#graphqleditor > * {
height: 100%;
width: 100%;
margin: 0;
overflow: hidden;

box-sizing: border-box;
}
</style>
6 changes: 2 additions & 4 deletions formwidgets/graphqlschemaeditor/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const UIDiagramFull = style({
});

// @ts-ignore
const schemaInput = document.getElementById(graphqlEditorValueId) as HTMLInputElement;
const schemaInput = document.getElementById(graphqlEditorValueId) as HTMLTextAreaElement;
// @ts-ignore
__webpack_public_path__ = myRuntimePublicPath;

Expand All @@ -35,9 +35,7 @@ export const App = () => {
});
return (
<div className={UiDiagram}>
<Editor schema={mySchema} graphController={controller => {
console.log(controller);
}}/>
<Editor schema={mySchema} />
</div>
);
};
Expand Down
106 changes: 0 additions & 106 deletions http/Controllers/GraphQLController.php

This file was deleted.

29 changes: 1 addition & 28 deletions routes.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
<?php

///** @var \Illuminate\Contracts\Routing\Registrar $router */
//$router = app('router');
//
//$router->group(config('thefehr.lighthouse::route', []), function () use ($router): void {
// $routeName = config('thefehr.lighthouse::route_name', 'graphql');
// $controller = config('thefehr.lighthouse::controller');
//
// $methods = config('thefehr.lighthouse::route_enable_get', false)
// ? ['GET', 'POST']
// : ['POST'];
//
// $router->match($methods, $routeName, [
// 'as' => 'lighthouse.graphql',
// 'uses' => $controller,
// ]);
//});

Route::group(config('thefehr.lighthouse::route', []), function () : void {
$routeName = config('thefehr.lighthouse::route_name', 'graphql');
$controller = config('thefehr.lighthouse::controller');
Expand All @@ -31,15 +13,6 @@
]);
});


Route::get('graphql/schema.graphql', function(){

$schemesBody = '';
$schemes = \TheFehr\Lighthouse\Models\Schema::published()->get();
foreach ($schemes as $schema) {
$schemesBody .= $schema->schema;
}

return $schemesBody;

return TheFehr\Lighthouse\Models\Settings::get('base_schema');
});

0 comments on commit 0173fea

Please sign in to comment.