ralphql_generator 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 424c0525b6ba37043784f664352284c95a761e514567097a1078e5a9a62f68ce
4
- data.tar.gz: b6f2c7930183531db5d6d7d674d346eb850e0ee1b7dc028daca13f5d75092db0
3
+ metadata.gz: e8278d980965a50cf221699198074e14b758846514211c87d7107fe778459540
4
+ data.tar.gz: 90414ffa8d3a00d48b991ea50145a5f1c3227d1b19f70fae6cf6bbefcc7b9c32
5
5
  SHA512:
6
- metadata.gz: 419ccaca078fd4e800ada37e6d7a92aa9462a11c2e26d42b7a1aacee9c19f10e6a4e4ae223f26bcd8e7b1aa243ab529aed7af379f8db458d7d4855d26a77b135
7
- data.tar.gz: c2384bd3f947cde30351f00f005257b281baf7bdc84cd20d43fd4fce8b7aea5bc61fabcffb37a016a7a2013e768fde89f0facc225374b0d583eaeac1cea21978
6
+ metadata.gz: a72a6b0e58aebed873ae8c34905be0612610a39cf6976a05dcb16649f63e2e149b01b0257de39774d337a18b27f8a9ddd2d13a4ab8e9f36e09141f9f0532232e
7
+ data.tar.gz: c1afed089919c60de724969df877bb5f18c7425e6e82e910a3530ca6d8b4e19242e2ae7bee38d5150a4ff54071d3b18e1f6cd574596a6324420b82c26414feed
@@ -5,7 +5,7 @@ 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
10
  template 'exemple.graphql.rb', File.join('spec/fixtures/graphql', "#{file_name.underscore.pluralize}.graphql")
11
11
  template 'exemple_type.rb', File.join('app/graphql/types', "#{file_name.underscore}_type.rb")
@@ -24,11 +24,5 @@ RSpec.describe Types::QueryType, type: :request do
24
24
  end
25
25
  end
26
26
 
27
- describe 'when unauthenticated' do
28
- before do
29
- do_graphql_request
30
- end
31
-
32
- include_examples 'when unauthenticated'
33
- end
27
+ include_examples 'when unauthenticated'
34
28
  end
@@ -4,6 +4,7 @@ require 'rails_helper'
4
4
 
5
5
  RSpec.describe Mutations::<%= class_name %>, type: :request do
6
6
  let(:query) { '<%= class_name.camelize(:lower) %>' }
7
+ let(:data) { json.dig(:data, :<%= class_name.camelize(:lower).pluralize %>, :change_me) }
7
8
 
8
9
  # let(:object) { Fabricate :object }
9
10
 
@@ -19,7 +20,6 @@ RSpec.describe Mutations::<%= class_name %>, type: :request do
19
20
  xit '<%= class_name %>' do
20
21
  do_graphql_request
21
22
  expect(errors).to be_blank
22
- data = json.dig('data', '<%= class_name.camelize(:lower) %>', 'object').deep_symbolize_keys
23
23
  expect(data).not_to be_empty
24
24
  end
25
25
  end
@@ -0,0 +1,5 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ bin/rails generate gql_show MyModel
@@ -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', "#{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
@@ -1,3 +1,3 @@
1
1
  module Ralphql
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.2"
3
3
  end
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.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Delpierre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-03 00:00:00.000000000 Z
11
+ date: 2024-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '7.0'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 7.0.4.3
19
+ version: '7.1'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '7.0'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 7.0.4.3
26
+ version: '7.1'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: puma
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -65,6 +59,10 @@ files:
65
59
  - lib/generators/gql_mutation/templates/exemple_mutation.graphql.rb
66
60
  - lib/generators/gql_mutation/templates/exemple_mutation.rb
67
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
68
66
  - lib/ralphql.rb
69
67
  - lib/ralphql/version.rb
70
68
  homepage: https://rubygems.org/gems/ralph_ql