Comments (4)
Hmmm, tricky! Some suggestions:
- Was there a preceeding error in your development server output? Sometimes one error can happen, then trigger a later error because the file couldn't be loaded properly.
- You can try adding a prefix
::
to clarify that you want a top-level constant. That might help rails load it properly (although it seems like it should work as written!), eg::Question.where(...)
. - What's the full path of the file where
class Question
is defined? (Is itapp/models/question.rb
?)
from graphiql-rails.
The full server output:
Started POST "/graphql" for 127.0.0.1 at 2019-02-27 13:48:01 -0700
Processing by GraphqlsController#create as */*
Parameters: {"query"=>"query {\n questions {\n uuid\n }\n}\n", "variables"=>nil, "graphql"=>{"query"=>"query {\n questions {\n uuid\n }\n}\n", "variables"=>nil}}
AuthToken Load (1.4ms) SELECT "auth_tokens".* FROM "auth_tokens" WHERE "auth_tokens"."expired_at" IS NULL AND "auth_tokens"."token" = $1 LIMIT $2 [["token", "**********"], ["LIMIT", 1]]
↳ app/controllers/application_controller.rb:35
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 4], ["LIMIT", 1]]
↳ app/controllers/application_controller.rb:42
(0.1ms) BEGIN
↳ app/controllers/application_controller.rb:42
AuthToken Update (0.3ms) UPDATE "auth_tokens" SET "last_used_at" = $1, "updated_at" = $2 WHERE "auth_tokens"."id" = $3 [["last_used_at", "2019-02-27 20:48:01.568622"], ["updated_at", "2019-02-27 20:48:01.571236"], ["id", 1]]
↳ app/controllers/application_controller.rb:42
(0.3ms) COMMIT
↳ app/controllers/application_controller.rb:42
Completed 500 Internal Server Error in 24ms (ActiveRecord: 6.2ms)
NameError (uninitialized constant Resolvers::Questions::Question):
app/graphql/resolvers/questions.rb:16:in `resolve'
app/controllers/graphqls_controller.rb:31:in `create'
I'm not seeing anything that points to a preceding error.
Adding the ::
prefix does work, but feels weird.
The Question class is defined as a Rails model (app/models/question.rb
). The core of the app can be thought of like a versioned question bank.
class Question < ApplicationRecord
include Trackable
include Identifiable
belongs_to :organization
has_many :question_versions
accepts_nested_attributes_for :question_versions
validates :name, presence: true
enum field_type: [
:short_text,
:paragraph_text,
:number,
:date,
:time,
:single_select,
:multi_select,
:likert,
:photo,
:audio,
:video,
]
def latest_version
question_versions.order(:version_number).last
end
end
from graphiql-rails.
Thanks for sharing! I was hoping to see a smoking gun, but nothin' 😖
I guess since the adding ::
works, we can be sure that the file does load correctly.
Sorry, I don't really have any other suggestion :(
If you don't like adding the explicit ::
, the other option is to manually load the file using require_dependency
at the top of the file, eg
require_dependency "question"
That will make sure Rails loads the file and can reload it as needed.
Sorry, I don't have any other ideas how graphiql-rails could be involved here!
from graphiql-rails.
Yeah, it occurs to me I probably should have opened the issue under the graphql-ruby
project instead.
My gut says it has everything to do with Rails' autoloading, especially since it's behaving differently in both prod and test environments vs local.
require_dependency 'question'
works and feels a little better than the ::
prefix.
I'll go with that for now. Thanks so much @rmosolgo for looking into it.
from graphiql-rails.
Related Issues (20)
- der
- Graphql query execute is getting freeze from model callbacks HOT 1
- Build issue when bumping graphiql-rails from 1.8.0 to 1.9.0 HOT 7
- doesn't work with propshaft HOT 2
- Using themes/custom CSS
- conditionally render route HOT 6
- onEditQuery is undefined HOT 1
- AbstractController::ActionNotFound (The action 'execute' could not be found for GraphqlController): HOT 1
- AssetNotPrecompiled error with Sprockets 4.0 HOT 27
- How to use this gem with graphql subscription? HOT 1
- default context variables HOT 1
- GraphiQL::Rails::EditorsController#show raising on new Rails 6 app HOT 3
- Question about request header configuration with initializer HOT 1
- Using GraphiQL in your Rails app without this gem HOT 7
- uninitialized constant GraphqlController::GraphQLIntroSchema Did you mean? GraphQlIntroSchema HOT 1
- Is this gem dead? HOT 1
- Support for subscriptions HOT 3
- headerEditorEnabled config HOT 1
- sass not needed anymore? HOT 2
- Your application has sessions disabled HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphiql-rails.