Skip to content

Commit

Permalink
chore: graphql schema can be generated in demo
Browse files Browse the repository at this point in the history
  • Loading branch information
plantain-00 committed Apr 17, 2018
1 parent e81823b commit c3b3f42
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
3 changes: 2 additions & 1 deletion online/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
}

.protobuf,
.json-schema {
.json-schema,
.graphql-schema {
display: block;
padding: 9.5px;
margin: 3px 0 10px 3px;
Expand Down
23 changes: 12 additions & 11 deletions online/index.template.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<div class="app">
<textarea class="source" v-model="source"></textarea>
<div class="result">
<button @click="generate()">generate</button>
<div class="options">
<select v-model="selectedOption">
<option v-for="option in options" :value="option" :key="option">{{option}}</option>
</select>
</div>
<pre class="protobuf" v-if="selectedOption === 'protobuf'">{{protobuf}}</pre>
<pre class="json-schema" v-if="jsonSchema">{{jsonSchema}}</pre>
<textarea class="source" v-model="source"></textarea>
<div class="result">
<button @click="generate()">generate</button>
<div class="options">
<select v-model="selectedOption">
<option v-for="option in options" :value="option" :key="option">{{option}}</option>
</select>
</div>
</div>
<pre class="protobuf" v-if="selectedOption === 'protobuf'">{{protobuf}}</pre>
<pre class="json-schema" v-if="jsonSchema">{{jsonSchema}}</pre>
<pre class="graphql-schema" v-if="selectedOption === 'graphql schema'">{{graphqlSchema}}</pre>
</div>
</div>
4 changes: 4 additions & 0 deletions online/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class App extends Vue {
protobuf = ''
options: string[] = ['protobuf']
selectedOption = 'protobuf'
graphqlSchema = ''
private innerSource = localStorage.getItem(localStorageKey) || demoCasesTs
private jsonSchemas: { entry: string; content: string }[] = []

Expand Down Expand Up @@ -48,10 +49,13 @@ export class App extends Vue {
content: JSON.stringify(s.schema, null, ' ')
}))

this.graphqlSchema = generator.generateGraphqlSchema()

this.options = ['protobuf']
for (const schema of this.jsonSchemas) {
this.options.push(schema.entry)
}
this.options.push('graphql schema')
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion online/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export type EntryType = {
}
`
// @ts-ignore
export function indexTemplateHtml(this: App) {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"app"},[_c('textarea',{directives:[{name:"model",rawName:"v-model",value:(_vm.source),expression:"source"}],staticClass:"source",domProps:{"value":(_vm.source)},on:{"input":function($event){if($event.target.composing){ return; }_vm.source=$event.target.value}}}),_vm._v(" "),_c('div',{staticClass:"result"},[_c('button',{on:{"click":function($event){_vm.generate()}}},[_vm._v("generate")]),_vm._v(" "),_c('div',{staticClass:"options"},[_c('select',{directives:[{name:"model",rawName:"v-model",value:(_vm.selectedOption),expression:"selectedOption"}],on:{"change":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return val}); _vm.selectedOption=$event.target.multiple ? $$selectedVal : $$selectedVal[0]}}},_vm._l((_vm.options),function(option){return _c('option',{key:option,domProps:{"value":option}},[_vm._v(_vm._s(option))])}))]),_vm._v(" "),(_vm.selectedOption === 'protobuf')?_c('pre',{staticClass:"protobuf"},[_vm._v(_vm._s(_vm.protobuf))]):_vm._e(),_vm._v(" "),(_vm.jsonSchema)?_c('pre',{staticClass:"json-schema"},[_vm._v(_vm._s(_vm.jsonSchema))]):_vm._e()])])}
export function indexTemplateHtml(this: App) {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"app"},[_c('textarea',{directives:[{name:"model",rawName:"v-model",value:(_vm.source),expression:"source"}],staticClass:"source",domProps:{"value":(_vm.source)},on:{"input":function($event){if($event.target.composing){ return; }_vm.source=$event.target.value}}}),_vm._v(" "),_c('div',{staticClass:"result"},[_c('button',{on:{"click":function($event){_vm.generate()}}},[_vm._v("generate")]),_vm._v(" "),_c('div',{staticClass:"options"},[_c('select',{directives:[{name:"model",rawName:"v-model",value:(_vm.selectedOption),expression:"selectedOption"}],on:{"change":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return val}); _vm.selectedOption=$event.target.multiple ? $$selectedVal : $$selectedVal[0]}}},_vm._l((_vm.options),function(option){return _c('option',{key:option,domProps:{"value":option}},[_vm._v(_vm._s(option))])}))]),_vm._v(" "),(_vm.selectedOption === 'protobuf')?_c('pre',{staticClass:"protobuf"},[_vm._v(_vm._s(_vm.protobuf))]):_vm._e(),_vm._v(" "),(_vm.jsonSchema)?_c('pre',{staticClass:"json-schema"},[_vm._v(_vm._s(_vm.jsonSchema))]):_vm._e(),_vm._v(" "),(_vm.selectedOption === 'graphql schema')?_c('pre',{staticClass:"graphql-schema"},[_vm._v(_vm._s(_vm.graphqlSchema))]):_vm._e()])])}
// @ts-ignore
export var indexTemplateHtmlStatic = [ ]
// tslint:enable

0 comments on commit c3b3f42

Please sign in to comment.