site_blog 0.6.0 → 0.8.0

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: 06fc6ef0736ab3372d299ef20a35998019629c62043316a0a018f53d56da11bb
4
- data.tar.gz: fe7218b9491eebb51a25e9903fa503c124a0116321477174feab66153093cc99
3
+ metadata.gz: a1c17bed2d9dfb9c42207ed00b2958f8d412f011a4cd0789253d0f7fd84fdb9a
4
+ data.tar.gz: 32877ba756d06b0a139a43d1f4f6e806e54430bc7131109a434bf3b0e0897371
5
5
  SHA512:
6
- metadata.gz: 3d1a252fbf87b87056223cce8e7b0d234266e6ec788e91354daf6866202f034bd858588e05f373e5f3d13e4822537be77465a5257556f1228dfe040a3405ca06
7
- data.tar.gz: 2eccec756cd91ce135fcb6479e1df0bcbb99a0a41f401986a505a8167c9fc79bac9dcf9684fc217fc1b41c8c9dd8a9593d3a36d5006a7cfa7755ec343801ed6b
6
+ metadata.gz: 155d5b8e30636d78c1dafe191d72f11dc9bb0bc4d96fc8d3d54318d20553201bbd12d72acb244ad4e9b6caf888be9408a36ff9c7614f0167c3973b331e24e4c5
7
+ data.tar.gz: fc947d550f5cd921f66571189072041915af772deebe5a4aee74947dc6822f8408c4f09272697481d4b2a20f232f0eb177fb3a577e3ccc565bd4df0c83689dc1
data/config/routes.rb CHANGED
@@ -1,8 +1,4 @@
1
1
  SiteBlog::Engine.routes.draw do
2
-
3
- mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: '/blog/graphql'
4
-
5
- post '/graphql', to: 'graphql#execute'
6
2
  resources :tags
7
3
  resources :articles
8
4
  end
@@ -2,8 +2,6 @@ require 'carrierwave'
2
2
  require 'pg_search'
3
3
  require 'kaminari'
4
4
  require 'translit'
5
- require 'graphql'
6
- require 'graphiql/rails'
7
5
 
8
6
  module SiteBlog
9
7
  class Engine < ::Rails::Engine
@@ -1,3 +1,3 @@
1
1
  module SiteBlog
2
- VERSION = "0.6.0"
2
+ VERSION = "0.8.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: site_blog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eldar
@@ -80,34 +80,6 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: graphql
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: graphiql-rails
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
83
  - !ruby/object:Gem::Dependency
112
84
  name: activeadmin_addons
113
85
  requirement: !ruby/object:Gem::Requirement
@@ -136,22 +108,7 @@ files:
136
108
  - app/assets/stylesheets/site_blog/application.css
137
109
  - app/controllers/site_blog/application_controller.rb
138
110
  - app/controllers/site_blog/articles_controller.rb
139
- - app/controllers/site_blog/graphql_controller.rb
140
111
  - app/controllers/site_blog/tags_controller.rb
141
- - app/graphql/site_blog/mutations/base_mutation.rb
142
- - app/graphql/site_blog/schema.rb
143
- - app/graphql/site_blog/types/article_type.rb
144
- - app/graphql/site_blog/types/base_argument.rb
145
- - app/graphql/site_blog/types/base_enum.rb
146
- - app/graphql/site_blog/types/base_field.rb
147
- - app/graphql/site_blog/types/base_input_object.rb
148
- - app/graphql/site_blog/types/base_interface.rb
149
- - app/graphql/site_blog/types/base_object.rb
150
- - app/graphql/site_blog/types/base_scalar.rb
151
- - app/graphql/site_blog/types/base_union.rb
152
- - app/graphql/site_blog/types/mutation_type.rb
153
- - app/graphql/site_blog/types/query_type.rb
154
- - app/graphql/site_blog/types/tag_type.rb
155
112
  - app/helpers/site_blog/application_helper.rb
156
113
  - app/helpers/site_blog/articles_helper.rb
157
114
  - app/helpers/site_blog/tags_helper.rb
@@ -1,52 +0,0 @@
1
- module SiteBlog
2
- class GraphqlController < ApplicationController
3
- # If accessing from outside this domain, nullify the session
4
- # This allows for outside API access while preventing CSRF attacks,
5
- # but you'll have to authenticate your user separately
6
- # protect_from_forgery with: :null_session
7
-
8
- def execute
9
- variables = prepare_variables(params[:variables])
10
- query = params[:query]
11
- operation_name = params[:operationName]
12
- context = {
13
- # Query context goes here, for example:
14
- # current_user: current_user,
15
- }
16
- result = Schema.execute(query, variables: variables, context: context, operation_name: operation_name)
17
- render json: result
18
- rescue StandardError => e
19
- raise e unless Rails.env.development?
20
- handle_error_in_development(e)
21
- end
22
-
23
- private
24
-
25
- # Handle variables in form data, JSON body, or a blank value
26
- def prepare_variables(variables_param)
27
- case variables_param
28
- when String
29
- if variables_param.present?
30
- JSON.parse(variables_param) || {}
31
- else
32
- {}
33
- end
34
- when Hash
35
- variables_param
36
- when ActionController::Parameters
37
- variables_param.to_unsafe_hash # GraphQL-Ruby will validate name and type of incoming variables.
38
- when nil
39
- {}
40
- else
41
- raise ArgumentError, "Unexpected parameter: #{variables_param}"
42
- end
43
- end
44
-
45
- def handle_error_in_development(e)
46
- logger.error e.message
47
- logger.error e.backtrace.join("\n")
48
-
49
- render json: { errors: [{ message: e.message, backtrace: e.backtrace }], data: {} }, status: 500
50
- end
51
- end
52
- end
@@ -1,10 +0,0 @@
1
- module SiteBlog
2
- module Mutations
3
- class BaseMutation < GraphQL::Schema::RelayClassicMutation
4
- argument_class Types::BaseArgument
5
- field_class Types::BaseField
6
- input_object_class Types::BaseInputObject
7
- object_class Types::BaseObject
8
- end
9
- end
10
- end
@@ -1,28 +0,0 @@
1
- module SiteBlog
2
- class Schema < GraphQL::Schema
3
- mutation(Types::MutationType)
4
- query(Types::QueryType)
5
-
6
- # For batch-loading (see https://graphql-ruby.org/dataloader/overview.html)
7
- use GraphQL::Dataloader
8
-
9
- # GraphQL-Ruby calls this when something goes wrong while running a query:
10
- def self.type_error(err, context)
11
- # if err.is_a?(GraphQL::InvalidNullError)
12
- # # report to your bug tracker here
13
- # return nil
14
- # end
15
- super
16
- end
17
-
18
- # Union and Interface Resolution
19
- def self.resolve_type(abstract_type, obj, ctx)
20
- # TODO: Implement this method
21
- # to return the correct GraphQL object type for `obj`
22
- raise(GraphQL::RequiredImplementationMissingError)
23
- end
24
-
25
- # Stop validating when it encounters this many errors:
26
- validate_max_errors(100)
27
- end
28
- end
@@ -1,12 +0,0 @@
1
- module SiteBlog
2
- module Types
3
- class ArticleType < Types::BaseObject
4
- description "A blog article"
5
- field :id, ID, null: false
6
- field :title, String, null: false
7
- field :html_description, String, null: false
8
- field :tag, TagType, null: false, description: "This post's tag"
9
- field :created_at, GraphQL::Types::ISO8601DateTime, null: false
10
- end
11
- end
12
- end
@@ -1,6 +0,0 @@
1
- module SiteBlog
2
- module Types
3
- class BaseArgument < GraphQL::Schema::Argument
4
- end
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module SiteBlog
2
- module Types
3
- class BaseEnum < GraphQL::Schema::Enum
4
- end
5
- end
6
- end
@@ -1,7 +0,0 @@
1
- module SiteBlog
2
- module Types
3
- class BaseField < GraphQL::Schema::Field
4
- argument_class Types::BaseArgument
5
- end
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- module SiteBlog
2
- module Types
3
- class BaseInputObject < GraphQL::Schema::InputObject
4
- argument_class Types::BaseArgument
5
- end
6
- end
7
- end
@@ -1,9 +0,0 @@
1
- module SiteBlog
2
- module Types
3
- module BaseInterface
4
- include GraphQL::Schema::Interface
5
-
6
- field_class Types::BaseField
7
- end
8
- end
9
- end
@@ -1,7 +0,0 @@
1
- module SiteBlog
2
- module Types
3
- class BaseObject < GraphQL::Schema::Object
4
- field_class Types::BaseField
5
- end
6
- end
7
- end
@@ -1,6 +0,0 @@
1
- module SiteBlog
2
- module Types
3
- class BaseScalar < GraphQL::Schema::Scalar
4
- end
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module SiteBlog
2
- module Types
3
- class BaseUnion < GraphQL::Schema::Union
4
- end
5
- end
6
- end
@@ -1,11 +0,0 @@
1
- module SiteBlog
2
- module Types
3
- class MutationType < Types::BaseObject
4
- # TODO: remove me
5
- field :test_field, String, null: false, description: "An example field added by the generator"
6
- def test_field
7
- "Hello World"
8
- end
9
- end
10
- end
11
- end
@@ -1,38 +0,0 @@
1
- module SiteBlog
2
- module Types
3
- class QueryType < Types::BaseObject
4
-
5
- field :articles, [ArticleType], null: false, description: "Вывод всех постов" do
6
- argument :page, Int, required: false, description: 'Номер страницы'
7
- argument :tag_id, Int, required: false, description: 'ID тега'
8
- argument :query, String, required: false, description: 'Поисковый запрос'
9
- end
10
-
11
- def articles(page: 1, tag_id: nil, query: nil)
12
- Article.preload(:tag).filters({page: page, tag_id: tag_id, query: query})
13
- end
14
-
15
- field :article, ArticleType, "Поиск поста по ID" do
16
- argument :id, ID
17
- end
18
-
19
- def article(id:)
20
- Article.find(id)
21
- end
22
-
23
- field :tags, [TagType], null: false, description: "Вывод всех тегов"
24
- def tags
25
- Tag.all
26
- end
27
-
28
- field :tag, TagType, "Поиск тега по ID" do
29
- argument :id, ID
30
- end
31
-
32
- def tag(id:)
33
- Tag.find(id)
34
- end
35
-
36
- end
37
- end
38
- end
@@ -1,9 +0,0 @@
1
- module SiteBlog
2
- module Types
3
- class TagType < Types::BaseObject
4
- description "A blog tag"
5
- field :id, ID, null: false
6
- field :title, String, null: false
7
- end
8
- end
9
- end