I get the following error when i query allTodos index through graphql
"errors": [
{
"message": "Cannot return null for non-nullable type (line 4, column 7):\n todo\n ^",
"path": [
"allTodos",
"data",
0,
"todo"
],
"locations": [
{
"line": 4,
"column": 7
}
]
},
My schema
enum Priority {
P1
P2
P3
P4
}
type Todo @embedded {
todo: String!
description: String!
status: Boolean!
date: String!
priority: Priority
uid: ID!
subtodos: [Todo!]
comments: [String!]
reminders: [String!]
}
input TodoInput {
todo: String!
description: String!
status: Boolean!
date: String!
priority: Priority
uid: ID!
subtodos: [TodoInput!]
comments: [String!]
reminders: [String!]
}
type Query {
allTodos: [Todo!]!
findTodoByUid(uid: ID!): Todo!
}
type Mutation {
createSubTodo(parentId: ID!, newData: TodoInput!): Todo!
@resolver(name: "create_sub_todo")
}
this is how I am quering in graphql
{
allTodos {
data {
todo
}
}
}
Did you intend to have @embedded directive?
yes,
As i have UDfs that return type Todo.
Remove the @embedded
should be a part of type
. Here is more info and examples on how to use it.
no, It didn’t solved my problem.
@umer2001 Can you share your latest schema file and query that is failing?
@Jay-Fauna yeah sure
schema file,
enum Priority {
P1
P2
P3
P4
}
type Todo @embedded {
todo: String!
description: String!
status: Boolean!
date: String!
priority: Priority
uid: ID!
subtodos: [Todo!]
comments: [String!]
reminders: [String!]
}
input TodoInput {
todo: String!
description: String!
status: Boolean!
date: String!
priority: Priority
uid: ID!
subtodos: [TodoInput!]
comments: [String!]
reminders: [String!]
}
type Query {
allTodos: [Todo!]!
findTodoByUid(uid: ID!): Todo!
}
type Mutation {
createSubTodo(parentId: ID!, newData: TodoInput!): Todo!
@resolver(name: "create_sub_todo")
}
Query
{
allTodos {
data {
todo
}
}
}
I still see type Todo @embedded.
It should be just type Todo
.
type Todo {
todo: String!
description: String!
status: Boolean!
date: String!
priority: Priority
uid: ID!
subtodos: [Todo!]
comments: [String!]
reminders: [String!]
}
I removed that and was able to import the schema and run the query.
Few other observations in your schema file.
- You don’t need
findTodoByUid(uid: ID!): Todo!
as Fauna by default provides you findTodoByID(id: ID!): Todo
- You don’t need
input TodoInput
as Fauna creates an InputType for every type by default.
@Jay-Fauna did you added an new document to test?
because today I deleted all the documents and ran the query and it was sucessful with no error after that I created a document from graphql playground, the document was created but returned with some sort of error after that I queried again and same error displayed as above…
Unfortunatly, I don’t remember the error which was recived in response of document creation & and cant’t get that aain as Lastly I tred to overide schema from UI that returned with the error “Error overriding GraphQL schema.
Instance data is not valid.”
Now I can’t do anything.
@umer2001 your database seems to be corrupted. Can you please reimport your schema into a new database?
@Jay-Fauna today I also tried to make new db and import schema in it but same error “RESPONSE:
Instance data is not valid.”
my schema
enum Priority {
P1
P2
P3
P4
}
type Todo @embedded {
todo: String!
description: String!
status: Boolean!
date: String!
priority: Priority
uid: ID!
subtodos: [Todo!]
comments: [String!]
reminders: [String!]
}
input TodoInput {
todo: String!
description: String!
status: Boolean!
date: String!
priority: Priority
uid: ID!
subtodos: [TodoInput!]
comments: [String!]
reminders: [String!]
}
type Query {
allTodos: [Todo!]!
findTodoByUid(uid: ID!): Todo!
}
type Mutation {
createSubTodo(parentId: ID!, newData: TodoInput!): Todo!
@resolver(name: "create_sub_todo")
}
@umer2001 In your schema file, please update
type Todo @embedded {
to
type Todo {
@Jay-Fauna Thankyou veery much now it is working fine…
It means my first database was curropted and @embedded keyword was causing the error in New database.