Comments (17)
I also found you can receive this if you dont pass null: true|false
to a field.
from graphql-ruby.
Circling back, I was migrating from a REST based API to Graphql. My old project had a middleware (https://github.com/vigetlabs/olive_branch) which I had forgotten to disable, so this was causing it to auto change snake case (which it identified __schema
as snake case) to CamelCase. My bad about this, but wanted to follow up in case anyone else had issues, maybe check your middlewares.
from graphql-ruby.
Hey, I opened a PR which fixes this issue 👉 howtographql/howtographql#897
from graphql-ruby.
Ok thanks so I have to change to basenode instead great will try that
from graphql-ruby.
I got this error but it turned out to be a mistake with the type of one of the fields I declared.
from graphql-ruby.
I have exactly the same issue. Does anyone know how to fix it?
from graphql-ruby.
Fixed at #897, you may close this one ;)
from graphql-ruby.
I still have this issues...
from graphql-ruby.
Hello,
I'm having the same issue doing the same tutorial.
I copied the entire code from yours and getting the same error.
TypeError: Cannot read property 'types' of undefined
at buildClientSchema (http://localhost:3000/assets/graphiql/rails/graphiql-0.12.0.self-84a2376c545f0620e86ec9d8681863a2f1b56b5eb3fe74c45003ff1fb982c1a3.js?body=1:33481:72)
at http://localhost:3000/assets/graphiql/rails/graphiql-0.12.0.self-84a2376c545f0620e86ec9d8681863a2f1b56b5eb3fe74c45003ff1fb982c1a3.js?body=1:2174:55
Thanks for help
from graphql-ruby.
Can you give me a link to repo with steps you have so far?
from graphql-ruby.
Yes sharing the link thanks
https://github.com/Jakub41/GraphQL-Ruby-Server
from graphql-ruby.
@Jakub41 @paw3lgora I found the issue. It was inheriting from BaseNode
, not BaseObject
:
diff --git a/app/graphql/types/link_type.rb b/app/graphql/types/link_type.rb
index f76eb79..07fe5cb 100644
--- a/app/graphql/types/link_type.rb
+++ b/app/graphql/types/link_type.rb
@@ -1,5 +1,6 @@
module Types
- class LinkType < BaseNode
+ class LinkType < BaseObject
+ field :id, ID, null: false
field :created_at, DateTimeType, null: false
field :url, String, null: false
field :description, String, null: false
diff --git a/app/graphql/types/user_type.rb b/app/graphql/types/user_type.rb
index 8afeeef..a7ea514 100644
--- a/app/graphql/types/user_type.rb
+++ b/app/graphql/types/user_type.rb
@@ -1,5 +1,6 @@
module Types
- class UserType < BaseNode
+ class UserType < BaseObject
+ field :id, ID, null: false
field :created_at, DateTimeType, null: false
field :name, String, null: false
field :email, String, null: false
diff --git a/app/graphql/types/vote_type.rb b/app/graphql/types/vote_type.rb
index 719638a..a5a2c38 100644
--- a/app/graphql/types/vote_type.rb
+++ b/app/graphql/types/vote_type.rb
@@ -1,5 +1,6 @@
module Types
- class VoteType < BaseNode
+ class VoteType < BaseObject
+ field :id, ID, null: false
field :created_at, DateTimeType, null: false
field :user, UserType, null: false
field :link, LinkType, null: false
BaseNode
was part of a chapter in the tutorial, which didn't make the cut. It is part of the repo code though.
from graphql-ruby.
I just ran into the same issue with the same errors, so it seems the PR didn't fix it :(
from graphql-ruby.
Hey, does this help
from graphql-ruby.
frankly, i'm not sure what to do with that comment - do i replace baseObject with BaseNode on linkType? i haven't even gotten as far as UserType or VoteType.
if that's the case ( replacing BaseObject with BaseNode), that doesn't work for me - i still get the same error
TypeError: Cannot read property 'types' of undefined
at buildClientSchema (http://localhost:3000/assets/graphiql/rails/graphiql-0.12.0.self-84a2376c545f0620e86ec9d8681863a2f1b56b5eb3fe74c45003ff1fb982c1a3.js?body=1:33481:72)
at http://localhost:3000/assets/graphiql/rails/graphiql-0.12.0.self-84a2376c545f0620e86ec9d8681863a2f1b56b5eb3fe74c45003ff1fb982c1a3.js?body=1:2174:55
from graphql-ruby.
@runn-vermel can you send me link to the repo to check out?
from graphql-ruby.
I recently got this error. I am running rails 6, graphiql-rails (1.7.0) and graphql (1.10.5). I had built it as an API but then added the necessary configurations to run graphiql in local development, including adding an app/assetts/config/manifest.js
with
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
The error I am receiving is:
TypeError: Cannot read property 'types' of undefined
at buildClientSchema (http://localhost:3000/assets/graphiql/rails/application-6f03c7a92432765b0fbe671bfb7a292ee6c37e6704b6e6ac95587e45676bbf72.js:34102:72)
at http://localhost:3000/assets/graphiql/rails/application-6f03c7a92432765b0fbe671bfb7a292ee6c37e6704b6e6ac95587e45676bbf72.js:2795:55
I tried deleting my graphql directory and re-doing the rails generate graphql:install
.
I was able to look into it more - I made a breakpoint in the chrome debugger for line 34,102, which has the following code:
function buildClientSchema(introspection, options) {
// Get the schema from the introspection result.
var schemaIntrospection = introspection.__schema;
// Converts the list of types into a keyMap based on the type names.
var typeIntrospectionMap = (0, _keyMap2.default)(schemaIntrospection.types, function (type) {
return type.name;
});
..... more code ......
The issue is with schemaIntrospection.types
, schemaIntrospection
is undefined. So above, I inspected the introspection
variable which calls introspection.__schema
- The introspection
variable looked like:
{"Schema":
{"queryType": {"name":"Query"},
"mutationType": {"name":"Mutation"},
"subscriptionType":null,
.... more JSON ...
So, what I ended up doing is instead of having var schemaIntrospection = introspection.__schema;
, I set the schemaIntrospection
variable using the correct key:
var schemaIntrospection = introspection.Schema;
And it worked! For that specific call only :/ , as I had used the interactive debugger
Does anyone know how I can fix this with ruby-graphql more permanently?
I want to be able to use the Documentation Explorer
Thanks!
from graphql-ruby.
Related Issues (20)
- Best practices for testing. HOT 6
- Could not run bundle install from freshly cloned repo. "Could not find rubocop-rails-0.4.1 in any of the sources" HOT 1
- Count on resolver HOT 1
- iso8601 loses data
- Filtering doesn't appear to work as expected HOT 5
- DateTimeType undefined HOT 5
- Test Failure: Resolvers::LinksSearchTest#test_filter_option [/test/graphql/resolvers/links_search_test.rb:42] HOT 2
- Can't technically "Complete" the tutorial
- Update Rails to 6.0? HOT 3
- Add subscriptions
- Default pagination HOT 1
- Issue with GraphQL::Types::ISO8601DateTime
- TypeError: Cannot read property 'types' of undefined on tutorial https://www.howtographql.com/graphql-ruby/7-filtering/ HOT 1
- Connecting with howtographql/react-apollo HOT 1
- Incorrect defining of type in links_search HOT 1
- "Cannot return null for non-nullable field CreateUserPayload.user"
- react-apollo AllLinksSearchQuery does not work HOT 1
- Confusing param :email HOT 5
- Graphql controller has incorrect variable name 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 graphql-ruby.