-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsagittarius_schema.rb
More file actions
75 lines (61 loc) · 2.33 KB
/
Copy pathsagittarius_schema.rb
File metadata and controls
75 lines (61 loc) · 2.33 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# frozen_string_literal: true
# rubocop:disable GraphQL/MaxComplexitySchema
class SagittariusSchema < GraphQL::Schema
mutation(Types::MutationType)
query(Types::QueryType)
subscription(Types::SubscriptionType)
default_max_page_size 50
max_depth 20
connections.add(ActiveRecord::Relation, Sagittarius::Graphql::StableConnection)
use GraphQL::Subscriptions::ActionCableSubscriptions
# For batch-loading (see https://graphql-ruby.org/dataloader/overview.html)
use GraphQL::Dataloader
use GraphQL::Schema::Visibility, preload: true, profiles: {
execution: {},
types: {},
docs: {},
full: {},
}
# rubocop:enable GraphQL/MaxComplexitySchema
# rubocop:disable Lint/UselessMethodDefinition
# GraphQL-Ruby calls this when something goes wrong while running a query:
def self.type_error(err, context)
# if err.is_a?(GraphQL::InvalidNullError)
# # report to your bug tracker here
# return nil
# end
super
end
# rubocop:enable Lint/UselessMethodDefinition
# rubocop:disable Lint/UnusedMethodArgument
# Union and Interface Resolution
def self.resolve_type(abstract_type, obj, ctx)
# TODO: Implement this method
# to return the correct GraphQL object type for `obj`
raise(GraphQL::RequiredImplementationMissingError)
end
# Stop validating when it encounters this many errors:
validate_max_errors(100)
# Relay-style Object Identification:
# Return a string UUID for `object`
def self.id_from_object(object, type_definition = nil, query_ctx = nil)
# For example, use Rails' GlobalID library (https://github.com/rails/globalid):
object.to_gid_param
end
# Given a string UUID, find the object
def self.object_from_id(global_id, query_ctx = nil)
# For example, use Rails' GlobalID library (https://github.com/rails/globalid):
GlobalID.find(global_id)
rescue ActiveRecord::RecordNotFound
nil
end
# rubocop:enable Lint/UnusedMethodArgument
end
if Types::BaseObject.instance_variable_defined?(:@user_ability_types)
Types::BaseObject.remove_instance_variable(:@user_ability_types) # release temporary type map
end
# Override description from the gem to fix line length
GraphQL::Types::String.description <<~DESC
Represents textual data as UTF-8 character sequences.
This type is most often used by GraphQL to represent free-form human-readable text.
DESC