cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Query multiple types with GraphQLs Union or Interface

Came across an issue and I'm not sure why im not getting it to work...

I want to query 2 object types in one query because I want them all preferably ordered by date from Neo4j. Im trying both Interface and Union with no luck... Not sure what im missing...

So, tried to create a query on a union type with and without cypher statement, and similarly with an interface. With union both with cypher statement and without (in the query) I get error.
With the interface I get error when having cypher statement or an empty array without cypher statement. makeAugumentedSchema doesn't seem to generate a query from an interface in the schema.

Examples:

With Union:
union Transaction = Order | OtherTransaction

the query:
Transaction(year: Int): [Transaction] @cypher(statement:"MATCH (n:Order), (m:OtherTransaction) RETURN n,m")

Error:
"message": "schemaType.getFields is not a function"

With Interface:
interface Transaction{
currency: String! #just as an example,
#transactiontime: DateTime (DateTime doesn't work here, requires _Neo4jDateTime)
}
type Order implements Transaction{
orderID: ID!
currency: String!
transactiontime: DateTime
}
type OtherTransaction implements Transaction{
transactiontime: DateTime
currency: String!
amount: Float!
description: String
}

Query:
Transaction(year: Int): [Transaction] @cypher(statement:"MATCH (n:Order) RETURN n")

Gives Error msg:
"message": "Abstract type Transaction must resolve to an Object type at runtime for field Query.Transaction with value {}, received "undefined". Either the Transaction type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.",

Without cypher statement in the query, it returns an empty array.


The data in Neo4j is loaded with load CSV for now, as
(n:Order)-->(t:Trade) (multiple orders related to 1 trade)
(x:OtherTransaction) (no relationships)

0 REPLIES 0