ibrain-core 0.2.8 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/ibrain/core/graphql_controller.rb +2 -1
- data/app/graphql/ibrain/types/base_input_object.rb +6 -0
- data/lib/generators/ibrain/graphql/object_generator.rb +1 -0
- data/lib/generators/ibrain/graphql/templates/input.erb +13 -0
- data/lib/generators/ibrain/graphql/templates/mutation.erb +1 -0
- data/lib/generators/ibrain/graphql/type_generator.rb +15 -0
- data/lib/ibrain/core/version.rb +2 -2
- data/lib/tasks/ibrain/ridgepole.rake +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6772a14bc161414c6518bbf33f3c389e99c3d88d028aab31249ec9128b05522
|
4
|
+
data.tar.gz: 38ef4afc995c693376a7dd81f4a731c71c7d8339c8b834be7251a020ba97e88e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 919f8893a7f5d61ab4578873d2f0e7a0178ed2382fdd00fc4768fd5b00f6e6f181912e8288b61c18bf4ed3c065c26ccd56761036de793aab250edac1d1a683ae
|
7
|
+
data.tar.gz: 5ea76bd948c0dc92ae50a62a0e1f33e93220452b1539313c985bda94b773c2832a11b4714531a391d73148b7841611f002fea0955acfd91994e533c5c42c646f
|
@@ -32,7 +32,8 @@ module Ibrain
|
|
32
32
|
protected
|
33
33
|
|
34
34
|
def normalize_entity
|
35
|
-
return [params[:query], params[:
|
35
|
+
return [params[:query], prepare_variables(params[:variables]), params[:operationName]] if params[:variables].present?
|
36
|
+
return [params[:query], prepare_variables(params[:variables]), 'IntrospectionQuery'] if params[:query].try(:include?, 'IntrospectionQuery')
|
36
37
|
|
37
38
|
operations = prepare_variables(params[:operations])
|
38
39
|
query = operations['query']
|
@@ -4,6 +4,12 @@ module Ibrain
|
|
4
4
|
module Types
|
5
5
|
class BaseInputObject < GraphQL::Schema::InputObject
|
6
6
|
argument_class Ibrain::Types::BaseArgument
|
7
|
+
|
8
|
+
def to_params
|
9
|
+
ActionController::Parameters.new(
|
10
|
+
to_h.with_indifferent_access.transform_keys(&:underscore)
|
11
|
+
)
|
12
|
+
end
|
7
13
|
end
|
8
14
|
end
|
9
15
|
end
|
@@ -32,6 +32,7 @@ module Ibrain
|
|
32
32
|
create_dir('app/repositories') unless Dir.exist?('app/repositories')
|
33
33
|
|
34
34
|
template "object.erb", "#{options[:directory]}/types/objects/#{type_file_name}.rb"
|
35
|
+
template "input.erb", "#{options[:directory]}/types/input/#{input_file_name}.rb"
|
35
36
|
template "repository.erb", "app/repositories/#{type_name}_repository.rb"
|
36
37
|
end
|
37
38
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
<% module_namespacing_when_supported do -%>
|
4
|
+
module Types
|
5
|
+
module Input
|
6
|
+
class <%= input_ruby_name.split('::')[-1] %> < Ibrain::Types::BaseInputObject
|
7
|
+
description '<%= input_ruby_name.split('::')[-1] %>'
|
8
|
+
|
9
|
+
<% normalized_fields.each do |f| %> <%= f.to_argument %>
|
10
|
+
<% end %>end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
<% end -%>
|
@@ -49,6 +49,8 @@ module Ibrain
|
|
49
49
|
else
|
50
50
|
["Types::#{type_expression.camelize}Type", null]
|
51
51
|
end
|
52
|
+
when :input
|
53
|
+
["Types::#{type_expression.camelize}Input", null]
|
52
54
|
when :graphql
|
53
55
|
[type_expression.camelize, null]
|
54
56
|
else
|
@@ -74,6 +76,15 @@ module Ibrain
|
|
74
76
|
@type_file_name ||= "#{type_graphql_name}Type".underscore
|
75
77
|
end
|
76
78
|
|
79
|
+
# @return [String] The user-provided type name, as a file name (without extension)
|
80
|
+
def input_file_name
|
81
|
+
@input_file_name ||= "#{type_graphql_name}Input".underscore
|
82
|
+
end
|
83
|
+
|
84
|
+
def input_ruby_name
|
85
|
+
@input_ruby_name ||= self.class.normalize_type_expression(type_name, mode: :input)[0]
|
86
|
+
end
|
87
|
+
|
77
88
|
# @return [Array<NormalizedField>] User-provided fields, in `(name, Ruby type name)` pairs
|
78
89
|
def normalized_fields
|
79
90
|
skip_fields = ["created_at:!Datetime", "updated_at:!Datetime"]
|
@@ -95,6 +106,10 @@ module Ibrain
|
|
95
106
|
def to_ruby
|
96
107
|
"field :#{@name}, #{@type_expr}, null: #{@null}"
|
97
108
|
end
|
109
|
+
|
110
|
+
def to_argument
|
111
|
+
"argument :#{@name}, #{@type_expr}, required: #{@null}"
|
112
|
+
end
|
98
113
|
end
|
99
114
|
end
|
100
115
|
end
|
data/lib/ibrain/core/version.rb
CHANGED
@@ -16,7 +16,8 @@ namespace :ridgepole do
|
|
16
16
|
desc 'import seed data'
|
17
17
|
task seed: :environment do
|
18
18
|
path = Rails.root.join("db/seeds/#{Rails.env}.rb")
|
19
|
-
path = path.sub(Rails.env, 'development') unless File.exist?(path)
|
19
|
+
path = path.sub(Rails.env, ENV.fetch('RAILS_ENV', 'development')) unless File.exist?(path)
|
20
|
+
|
20
21
|
require path
|
21
22
|
end
|
22
23
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ibrain-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tai Nguyen Van
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord-session_store
|
@@ -241,6 +241,7 @@ files:
|
|
241
241
|
- lib/generators/ibrain/graphql/resolver_generator.rb
|
242
242
|
- lib/generators/ibrain/graphql/resolvers_generator.rb
|
243
243
|
- lib/generators/ibrain/graphql/templates/aggregate.erb
|
244
|
+
- lib/generators/ibrain/graphql/templates/input.erb
|
244
245
|
- lib/generators/ibrain/graphql/templates/mutation.erb
|
245
246
|
- lib/generators/ibrain/graphql/templates/object.erb
|
246
247
|
- lib/generators/ibrain/graphql/templates/repository.erb
|