-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema_b.rb
55 lines (44 loc) · 863 Bytes
/
schema_b.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/ruby
require_relative './server.rb'
TEMPALTES = [
{
id: 1,
name: "awsome template",
body: "<% this %>"
},
{
id: 2,
name: "not so awsome template",
body: "<% this is %>"
},
{
id: 3,
name: "wrong template",
body: "<% this is a sample %>"
},
{
id: 4,
name: "right template",
body: "<% this is a samle of something %>"
},
]
class Template < BaseObject
key fields: [:id]
field :id, ID, null: false
field :name, String, null: false
field :body, String, null: false
def self.resolve_reference(reference, _context)
TEMPALTES.find{|t| t[:id].to_s == reference[:id] }
end
end
class SchemaB < GraphQL::Schema
include ApolloFederation::Schema
federation version: '2.0'
orphan_types Template
end
class App < SampleApp
def self.schema
SchemaB
end
end
App.run(5004)