需要将参数放在函数中,然后再使用 Cypher 语句。
示例代码:
const neo4jgraphql = require('neo4j-graphql-js');
const { makeAugmentedSchema } = require('neo4j-graphql-js');
const {ApolloServer} = require('apollo-server-express');
const express = require('express');
const typeDefs = `
type Movie {
title: String!
year: String!
}
type Query {
movies(title: String): [Movie]
}
`;
const schema = makeAugmentedSchema({ typeDefs });
const server = new ApolloServer({
schema,
context: ({ req }) => ({
driver,
req
})
});
const graphqlHandler = neo4jgraphql;
const app = express();
server.applyMiddleware({ app });
app.listen({ port: 4000 }, () => {
console.log(`� Server ready at http://localhost:4000${server.graphqlPath}`)
});