@things-factory/modeller-ui 4.0.0-y.0 → 4.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,17 +2,6 @@
2
2
  * @license Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
4
 
5
- import { LitElement, html, css, unsafeCSS } from 'lit-element'
6
- import { introspectSchema } from 'graphql-tools'
7
- import { createHttpLink } from 'apollo-link-http'
8
-
9
- import CodeMirrorStyle from '!!text-loader!codemirror/lib/codemirror.css'
10
- import FullScreenStyle from '!!text-loader!codemirror/addon/display/fullscreen.css'
11
- import LintStyle from '!!text-loader!codemirror/addon/lint/lint.css'
12
- import ShowHintStyle from '!!text-loader!codemirror/addon/hint/show-hint.css'
13
- import NightThemeStyle from '!!text-loader!codemirror/theme/night.css'
14
-
15
- import CodeMirror from 'codemirror'
16
5
  import 'codemirror/addon/display/fullscreen'
17
6
  import 'codemirror/addon/display/autorefresh'
18
7
  import 'codemirror/addon/hint/show-hint'
@@ -21,7 +10,18 @@ import 'codemirror-graphql/hint'
21
10
  import 'codemirror-graphql/lint'
22
11
  import 'codemirror-graphql/mode'
23
12
 
24
- import { client } from '@things-factory/shell'
13
+ import { GRAPHQL_URI, client } from '@things-factory/shell'
14
+ import { LitElement, css, html, unsafeCSS } from 'lit-element'
15
+ import { introspectSchema, wrapSchema } from '@graphql-tools/wrap'
16
+
17
+ import CodeMirror from 'codemirror'
18
+ import CodeMirrorStyle from '!!text-loader!codemirror/lib/codemirror.css'
19
+ import FullScreenStyle from '!!text-loader!codemirror/addon/display/fullscreen.css'
20
+ import LintStyle from '!!text-loader!codemirror/addon/lint/lint.css'
21
+ import NightThemeStyle from '!!text-loader!codemirror/theme/night.css'
22
+ import ShowHintStyle from '!!text-loader!codemirror/addon/hint/show-hint.css'
23
+ import { fetch } from 'cross-fetch'
24
+ import { print } from 'graphql'
25
25
 
26
26
  /**
27
27
  WEB Component for code-mirror graphql editor.
@@ -91,10 +91,34 @@ export default class ThingsEditorGraphql extends LitElement {
91
91
  return html` <textarea></textarea> `
92
92
  }
93
93
 
94
+ async getSchema() {
95
+ const executor = async ({ document, variables }) => {
96
+ const query = print(document)
97
+ const uri = this.link || GRAPHQL_URI
98
+
99
+ const fetchResult = await fetch(uri, {
100
+ method: 'POST',
101
+ headers: {
102
+ 'Content-Type': 'application/json'
103
+ },
104
+ body: JSON.stringify({ query, variables })
105
+ })
106
+ return fetchResult.json()
107
+ }
108
+
109
+ return await wrapSchema({
110
+ schema: await introspectSchema(executor),
111
+ executor
112
+ })
113
+ }
114
+
94
115
  async getEditor() {
95
116
  if (!this._editor) {
96
- const link = this.link ? createHttpLink({ uri: this.link }) : client.link
97
- const schema = await introspectSchema(link)
117
+ try {
118
+ var schema = await this.getSchema()
119
+ } catch (err) {
120
+ console.error(err)
121
+ }
98
122
 
99
123
  let textarea = this.shadowRoot.querySelector('textarea')
100
124
  if (textarea) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/modeller-ui",
3
- "version": "4.0.0-y.0",
3
+ "version": "4.0.5",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -24,7 +24,10 @@
24
24
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
25
25
  },
26
26
  "dependencies": {
27
- "@graphql-tools/wrap": "^8.0.8",
27
+ "@apollo/client": "^3.4.17",
28
+ "@graphql-tools/load": "^7.3.2",
29
+ "@graphql-tools/url-loader": "^7.2.0",
30
+ "@graphql-tools/wrap": "^8.1.1",
28
31
  "@material/mwc-icon": "^0.22.1",
29
32
  "@polymer/iron-flex-layout": "^3.0.1",
30
33
  "@polymer/iron-form-element-behavior": "^3.0.1",
@@ -39,17 +42,19 @@
39
42
  "@polymer/paper-ripple": "^3.0.2",
40
43
  "@polymer/paper-slider": "^3.0.1",
41
44
  "@polymer/polymer": "^3.3.1",
42
- "@things-factory/attachment-ui": "^4.0.0-y.0",
43
- "@things-factory/font-ui": "^4.0.0-y.0",
44
- "@things-factory/i18n-base": "^4.0.0-y.0",
45
+ "@things-factory/attachment-ui": "^4.0.5",
46
+ "@things-factory/font-ui": "^4.0.5",
47
+ "@things-factory/i18n-base": "^4.0.5",
45
48
  "ace-builds": "^1.4.11",
46
49
  "brace": "^0.11.1",
47
50
  "codemirror": "^5.59.1",
48
51
  "codemirror-graphql": "^0.15.2",
52
+ "cross-fetch": "^3.1.4",
53
+ "graphql": "^15.6.1",
49
54
  "tinycolor2": "^1.4.1"
50
55
  },
51
56
  "devDependencies": {
52
57
  "@types/codemirror": "^0.0.105"
53
58
  },
54
- "gitHead": "64ee0f6547f90b1386024b975efc3b31a5e381cb"
59
+ "gitHead": "b7b2976818dceab74a34903499d408eed5d45b04"
55
60
  }