Open iledzka opened 3 years ago
Hey there! Could you share a minimal example of your schema and a query that reproduces this error? Thank you 💯
I have run into a similar issue while trying to work with interface types. I am new to all of this, so please excuse my ignorance. In my situation, was trying to create a relationship between two interfaces, as part of an interface. To demonstrate, i will try to build off the example provided on the interface and union type page in the documentation:
`interface Person { personid: ID! name: String likes: [Likes] }
type Likes @relation(name: "LIKES") { from: Person to: Subject rating: Float }
interface Subject { subjectid: ID! name: String }
type Maths implements Subject { subjectid: ID! name: String level: String }
type User implements Person { personid: ID! name: String likes: [Likes] screenName: String }`
Adding the data:
mutation { u1: CreateUser(name: "Bob", screenName: "bobbyTables", personid: "u1") { personid } s1: CreateMaths(name: "Calculus", subjectid: "s1", level: "Undergrad") { name subjectid level } l1: AddUserLikes(from: { personid: "u1" }, to: { subjectid: "s1" }, data:{ rating: 3.3}) { from { personid } to { subjectid } rating } }
AddUserLikes does seem to establish the realationship, but results in this error for both Person and Subject:
"Abstract type \"Person\" must resolve to an Object type at runtime for field \"_AddUserLikesPayload.from\". Either the \"Person\" type should provide a \"resolveType\" function or each possible type should provide an \"isTypeOf\" function."
I don't remember receiving that error when making simiar additions in the past. I am not sure if am using proper technique. but when I try to query using the interfaces:
query { Person { likes { Subject { ... on Maths { name } } } } }
I recognize this query may be incorrect, but it is how I get an error similar to op (also if quering User):
"Invalid input ']': expected whitespace, comment or an expression (line 1, column 364 (offset: 363))\n\"MATCH (
person:
Person) RETURN
person{FRAGMENT_TYPE: head( [ label IN labels(
person) WHERE label IN $Person_derivedTypes ] ),likes: [(
person)-[
person_likes_relation:
LIKES]->(:
Subject) | person_likes_relation {Subject: head([(:
Person)-[
person_likes_relation]->(
person_likes_Subject:
Subject) WHERE (\"Maths\" IN labels(person_likes_Subject)) | ]) }] } AS
person\"\n
It definitely seems tied to the interface in my case. When I try the simple query:
query { Person { name } }
I get the previous abstract type error (even when following the documentation example exactly) :
Abstract type \"Person\" must resolve to an Object type at runtime for field \"Query.Person\". Either the \"Person\" type should provide a \"resolveType\" function or each possible type should provide an \"isTypeOf\" function.
Again, I am new to all this, so I understand I may be going about this all wrong. The fact that I can't even query Person has me worried, though. Any insight is greatly appreciated. Thanks!
Any updates regarding this issue?
Hey there! Could you share a minimal example of your schema and a query that reproduces this error? Thank you 💯
Apologies for late response. I reverted to 2.7.2 because this is for an app that it's in production ;) I created a new branch and tried to reproduce this and I can confirm that the bug is definitely related to Interfaces.
Schema:
interface Component {
id: ID!
title: String
...
}
interface Resource {
id: ID!
resourceOf: [Project] @relation(name: "HAS_RESOURCE", direction: "IN")
}
type Image implements Component & Resource (...& other interfaces...) {
id: ID!
title: String
subtitle: String
version: String
creationDate: _Neo4jDateTime
...
}
type Project implements Component & Resource {
id: ID!
resources: [Resource] @relation(name: "HAS_RESOURCE", direction: "OUT")
}
An example of a query:
query getProject(
$personId:ID!,
$projectId: ID!
) {
Project(
projectId: $projectId,
personId: $personId
) {
id,
resources {
...on Component {
id,
title
}
__typename
}
}
}
if I remove the fragment ...on Component, I don't get the error. If I change this fragment to be "...on Resources", I get different error:
"invalid literal number (line 1, column 568 (offset: 567))\n\"WITH apoc.cypher.runFirstColumn(\"MATCH(:Person {id: $personId})-[:HAS|HAS_MEMBER]-(project:Project {id: $projectId}) RETURN project\", {offset:$offset, first:$first, personId:$personId, projectId:$projectId}, True) AS x UNWIND x AS `project` RETURN `project` { .id ,resources: [(`project`)-[:`HAS_RESOURCE`]->(`project_resources`:`Resource`) WHERE (\"Image\" IN labels(`project_resources`) OR \"Recording\" IN labels(`project_resources`) OR \"SourceFile\" IN labels(`project_resources`) OR \"Text\" IN labels(`project_resources`) OR \"Video\" IN labels(`project_resources`)) | .id ] } AS `project`\"\n
Thanks for your help!
This issue should be resolved with the PR, I would be happy to hear if it worked for you too.
Whooo! That seems to work for me!! Thanks!
Hello,
I recently updated from the version 2.7.2 to 2.16.4 and this caused a lot of my queries to fail with error like this
"Invalid input ']': expected whitespace, comment or an expression
This is the debug output:
When I run this query in the neo4j browser, I get this:
Invalid input '\': expected whitespace, DISTINCT, an expression or ')' (line 1, column 33 (offset: 32))
Any help is appreciated.