Method: URI::GQL.build

Defined in:
lib/rails/graphql/uri.rb

.build(args) ⇒ Object

Create a new URI::GQL from components with argument check.

Using a hash:

URI::GQL.build(app: 'bcx', model_name: 'Person', model_id: '1', params: { key: 'value' })

Using an array, the arguments must be in order [app, model_name, model_id, params]:

URI::GQL.build(['bcx', 'Person', '1', key: 'value'])


72
73
74
75
76
77
78
79
80
81
# File 'lib/rails/graphql/uri.rb', line 72

def build(args)
  parts = Util.make_components_hash(self, args)
  parts[:host] = parts[:namespace].to_s.tr('_', '-')
  parts[:path] = [parts[:class_name], parts[:scope], parts[:name]].compact.join('/')
  parts[:path].prepend('/')

  parts[:query] = parts[:params].to_param unless parts[:params].nil?

  super parts
end