graphql-kit / graphql-voyager

🛰️ Represent any GraphQL API as an interactive graph
https://graphql-kit.com/graphql-voyager/
MIT License
7.69k stars 504 forks source link

TypeError: Cannot read properties of undefined (reading 'name') #378

Closed p1b1 closed 5 months ago

p1b1 commented 6 months ago

I came across this library and wanted to try it out. I can't figure out what the problem is. Is it something with the data I'm trying to enter into the SDL field in the live demo application? For example

type Query {
 id: ID
}

Graph is generated, but when, for example I change the name for a type and enter such data in the SDL input:

type QueryTest {
 id: ID
}

I get an error in the console

image

Can anyone explain what the problem is? It often happens that names for types are accepted in SDL input and a view is generated, but it looks like the library only accepts selected(?) names for types?

Another example: (work)

type Example {
  id: ID!
  name: String
}

type Query {
  getEx: [Example]
}

Error (as on the screenshot):

type Example {
  id: ID!
  name: String
}

type Query2 {
  getEx: [Example]
}
LunaticMuch commented 5 months ago

This is correct. By default the query root type is called Query. You can change it, but then you need also to add the schema definition

schema {
  query: Query2
}

Look the whole paragraph on the specs