在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):neo4j-graphql/neo4j-graphql-js开源软件地址(OpenSource Url):https://github.com/neo4j-graphql/neo4j-graphql-js开源编程语言(OpenSource Language):JavaScript 99.8%开源软件介绍(OpenSource Introduction):
neo4j-graphql.jsA GraphQL to Cypher query execution layer for Neo4j and JavaScript GraphQL implementations. neo4j-graphql.js is facilitated by Neo4j Labs. Installation and usageInstall
UsageStart with GraphQL type definitions: const typeDefs = `
type Movie {
title: String
year: Int
imdbRating: Float
genres: [Genre] @relation(name: "IN_GENRE", direction: "OUT")
}
type Genre {
name: String
movies: [Movie] @relation(name: "IN_GENRE", direction: "IN")
}
`; Create an executable schema with auto-generated resolvers for Query and Mutation types, ordering, pagination, and support for computed fields defined using the import { makeAugmentedSchema } from 'neo4j-graphql-js';
const schema = makeAugmentedSchema({ typeDefs }); Create a neo4j-javascript-driver instance: import { v1 as neo4j } from 'neo4j-driver';
const driver = neo4j.driver(
'bolt://localhost:7687',
neo4j.auth.basic('neo4j', 'letmein')
); Use your favorite JavaScript GraphQL server implementation to serve your GraphQL schema, injecting the Neo4j driver instance into the context so your data can be resolved in Neo4j: import { ApolloServer } from 'apollo-server';
const server = new ApolloServer({ schema, context: { driver } });
server.listen(3003, '0.0.0.0').then(({ url }) => {
console.log(`GraphQL API ready at ${url}`);
}); If you don't want auto-generated resolvers, you can also call import { neo4jgraphql } from 'neo4j-graphql-js';
const resolvers = {
Query: {
Movie(object, params, ctx, resolveInfo) {
return neo4jgraphql(object, params, ctx, resolveInfo);
}
}
};
What is |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论