ralphql_generator 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/gql/gql_generator.rb +2 -2
- data/lib/generators/gql/templates/exemple.graphql.rb +1 -1
- data/lib/generators/gql_show/USAGE +5 -0
- data/lib/generators/gql_show/gql_show_generator.rb +19 -0
- data/lib/generators/gql_show/templates/exemple.graphql.rb +8 -0
- data/lib/generators/gql_show/templates/exemple_spec.rb +27 -0
- data/lib/ralphql/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be006eee7c8a1522f23b45310160f5fa28f9e06055ae17e688b50dde66f72e37
|
4
|
+
data.tar.gz: a1ccc81a1548f68ba01ada191279bd159fa3f0ead2dfdf7dea21be5f3c0a0d70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e6b77190aa58a02464aefa2a7a3d07a0a5daf425d3378411fe96e644430e259ac571272432652e6f250c17991ba2e4c7b76d90a6e81718b34fcc3dea63fec62
|
7
|
+
data.tar.gz: 60b567c57e333ce7986d6e0d1a3f7739ef7a2f971a4691bfa6f7385bc6401d80c2427f945e50adf276b94deca14725e66026618cf83b4c2ed2675db40a3c794e
|
@@ -5,9 +5,9 @@ class GqlGenerator < Rails::Generators::NamedBase
|
|
5
5
|
|
6
6
|
def create_gql_file
|
7
7
|
template 'exemple_policy.rb', File.join('app/policies/', "#{file_name.underscore}_policy.rb")
|
8
|
-
template 'exemple_spec.rb', File.join('spec/graphql/queries', "#{file_name.underscore.pluralize}_spec.rb")
|
8
|
+
template 'exemple_spec.rb', File.join('spec/graphql/queries/types', "query_type_#{file_name.underscore.pluralize}_spec.rb")
|
9
9
|
template 'exemple_resolver.rb', File.join('app/graphql/resolvers', "#{file_name.underscore}_resolver.rb")
|
10
|
-
template 'exemple.graphql.rb', File.join('spec/fixtures/graphql', "#{file_name.underscore.pluralize}.graphql")
|
10
|
+
template 'exemple.graphql.rb', File.join('spec/fixtures/graphql/queries', "#{file_name.underscore.pluralize}.graphql")
|
11
11
|
template 'exemple_type.rb', File.join('app/graphql/types', "#{file_name.underscore}_type.rb")
|
12
12
|
insert_into_query_type
|
13
13
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
query <%= class_name.camelize(:lower).pluralize %>{
|
2
2
|
<%= class_name.camelize(:lower).pluralize %>{
|
3
|
-
nodes{
|
3
|
+
nodes {
|
4
4
|
<%- class_name.constantize.columns.each do |column| -%>
|
5
5
|
<%- next if class_name.constantize.reflect_on_all_associations.map(&:foreign_key).include?(column.name) -%>
|
6
6
|
<%= column.name.camelize(:lower)%>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GqlShowGenerator < Rails::Generators::NamedBase
|
4
|
+
source_root File.expand_path('templates', __dir__)
|
5
|
+
|
6
|
+
def create_gql_file
|
7
|
+
template 'exemple_spec.rb', File.join('spec/graphql/queries/types', "query_type_#{file_name.underscore}_spec.rb")
|
8
|
+
template 'exemple.graphql.rb', File.join('spec/fixtures/graphql/queries', "#{file_name.underscore}.graphql")
|
9
|
+
insert_into_query_type
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def insert_into_query_type
|
15
|
+
inject_into_file 'app/graphql/types/query_type.rb', after: "SHOW_QUERIES_FOR_SINGLE_RECORDS = %w[" do
|
16
|
+
"#{file_name.camelize(:lower)} "
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
query <%= class_name.camelize(:lower) %>($id: ID!) {
|
2
|
+
<%= class_name.camelize(:lower) %>(id: $id) {
|
3
|
+
<%- class_name.constantize.columns.each do |column| -%>
|
4
|
+
<%- next if class_name.constantize.reflect_on_all_associations.map(&:foreign_key).include?(column.name) -%>
|
5
|
+
<%= column.name.camelize(:lower)%>
|
6
|
+
<%- end -%>
|
7
|
+
}
|
8
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
RSpec.describe Types::QueryType, type: :request do
|
6
|
+
let(:query) { '<%= class_name.camelize(:lower) %>' }
|
7
|
+
let(:data) { json.dig(:data, :<%= class_name.camelize(:lower) %>) }
|
8
|
+
let(:<%= class_name.underscore %>) { Fabricate(:<%= class_name.underscore %>) }
|
9
|
+
let(:id) { id_from_object(<%= class_name.underscore %>) }
|
10
|
+
let(:variables) { { id: } }
|
11
|
+
|
12
|
+
describe '<%= class_name.underscore %>' do
|
13
|
+
it_behaves_like 'with standard user' do
|
14
|
+
before do
|
15
|
+
do_graphql_request
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'get a <%= class_name.underscore %>' do
|
19
|
+
raise "Change me or adopt me in #{__FILE__}"
|
20
|
+
expect(errors).to be_blank
|
21
|
+
expect(data[:id]).to eq(id)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
include_examples 'when unauthenticated'
|
27
|
+
end
|
data/lib/ralphql/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ralphql_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michel Delpierre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -59,6 +59,10 @@ files:
|
|
59
59
|
- lib/generators/gql_mutation/templates/exemple_mutation.graphql.rb
|
60
60
|
- lib/generators/gql_mutation/templates/exemple_mutation.rb
|
61
61
|
- lib/generators/gql_mutation/templates/exemple_mutation_spec.rb
|
62
|
+
- lib/generators/gql_show/USAGE
|
63
|
+
- lib/generators/gql_show/gql_show_generator.rb
|
64
|
+
- lib/generators/gql_show/templates/exemple.graphql.rb
|
65
|
+
- lib/generators/gql_show/templates/exemple_spec.rb
|
62
66
|
- lib/ralphql.rb
|
63
67
|
- lib/ralphql/version.rb
|
64
68
|
homepage: https://rubygems.org/gems/ralph_ql
|