Hey @smkhalsa - sorry for the delay. Thanks for the example, I was able to reproduce your error.
Unfortunately, we don't yet have support for union types, so I'm not surprised by the union error
But regarding the PlaylistInterface query - our initial interface implementation adds a FRAGMENT_TYPE
field to the generated Cypher query by inspecting the implemented type from the GraphQL resolveinfo object, with the idea that this FRAGMENT_TYPE
field is then picked up in the __resolveType
resolver. To make this work, augmentSchema
adds a __resolveType
resolver for any interfaces that is essentially this:
const resolvers = {
SomeInterface: {
__resolveType(obj, context, info){
return obj["FRAGMENT_TYPE"];
},
},
};
however, it looks like we don't check for already existing __resolveType
resolvers, so this ends up overwriting the __resolveType
resolvers you've implemented. This we can fix easily, in fact a workaround would be to use makeExecutableSchema
and implement a Query field resolver that just delegates to neo4jgraphql
:
import { makeExecutableSchema } from "apollo-server";
import { neo4jgraphql } from "neo4j-graphql-js";
...
const resolvers = {
Query: {
PlaylistInterface: neo4jgraphql
},
Playlist: {
__resolveType: (collection) => {
return collection.imageName ? "PublicPlaylist" : "UserPlaylist"
}
}
};
const schema = makeExecutableSchema({
resolvers,
typeDefs
});
const server = new ApolloServer({
schema,
resolvers,
context: { driver }
});
I tested this out and this does result in the provided __resolveType
resolver getting called, but we don't actually grab the imageName
field from the database since it isn't a field on Playlist
. I suppose we could add some logic to add all fields for the implemented type so they would be available in the __resolveType
resolver.
It seems something happened with our FRAGMENT_TYPE
approach as that doesn't appear to be working properly, and unfortunately we didn't have good tests around this so not sure what went wrong there. This will require some investigation.
I'll push a fix to check for implemented __resolveType
resolvers before adding them in the augment schema step for now. That's at least a start.
Thanks for bearing with us as we fix this up, I recognize the importance of getting interface and unions working properly.