I have a graph network with minimum info about products and their relations. All the detail information is in mysql database and available via a REST api call.
MY Schema:
type Product {
id: ID
name: String
details: ProductDetails
}
type ProductDetails {
product_id: ID
product_name: String
release_date: String,
status: String
}
type Query {
mergeProduct(id: Int!): Product
}
Try adding the @neo4j_ignore directive to the details field in your typedefs. This directive will ensure that field is explicitly ignored by neo4j-graphql.js.
Here's a very similar example with a mocked up resolver (I just changed Product --> Business so it would work with an example database I have) running in CodeSandbox: neo4j-graphql-js custom resolvers example - CodeSandbox
Try this GraphQL Query:
{
Business(first:1) {
name
details {
product_id
product_id
release_date
status
}
}
}
and the code
const { ApolloServer } = require("apollo-server");
const { makeAugmentedSchema } = require("neo4j-graphql-js");
const { v1 } = require("neo4j-driver");
// Construct a schema, using GraphQL schema language
const typeDefs = `
type Business {
name: String
details: ProductDetails @neo4j_ignore
}
type ProductDetails {
product_id: ID
produt_name: String
release_date: String
status: String
}
`;
const resolvers = {
Business: {
details: (obj, params, ctx, resolveInfo) => {
return {
product_id: "2342lkajldf",
produt_name: "Bob Loblaw",
release_date: "12/10/2019",
status: "pending"
};
}
}
};
// Generate executable schema with auto-generated resolvers
const schema = makeAugmentedSchema({ typeDefs, resolvers });
// Instantiate a Neo4j database driver
const driver = v1.driver(
"bolt+routing://d2e2ad3f.databases.neo4j.io",
v1.auth.basic("reviews", "reviews")
);
// Create a new ApolloServer, injecting the database driver
// into the context
const server = new ApolloServer({
context: { driver },
schema
});
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});