如何从neo4j-graphql-js使用makeAugmentedschema创建突变

时间:2019-10-21 07:53:24

标签: neo4j graphql

我可以使用makeAugmentedSchema创建查询和变异以查询/创建/更新/删除节点

请帮助您分享知识和一些示例,如何使用makeAugmentedSchema(不使用makeExecuteableSchema和resolvers)创建突变。

下面是我的index.js

import { typeDefs } from "./graphql-schema";
import { ApolloServer } from "apollo-server";
import { v1 as neo4j } from "neo4j-driver";
import { makeAugmentedSchema } from "neo4j-graphql-js";
import dotenv from "dotenv";

// set environment variables from ../.env
dotenv.config();

const schema = makeAugmentedSchema({
  typeDefs
});

const driver = neo4j.driver(
  process.env.NEO4J_URI || "bolt://localhost:7689",
  neo4j.auth.basic(
    process.env.NEO4J_USER || "neo4j",
    process.env.NEO4J_PASSWORD || "letmein"
  )
);


const server = new ApolloServer({
  context: { driver },
  schema: schema
});

server.listen(process.env.GRAPHQL_LISTEN_PORT, "0.0.0.0").then(({ url }) => {
  console.log(`GraphQL API ready at ${url}`);
});

下面是我的graph.schema.js

import { neo4jgraphql } from "neo4j-graphql-js";


export const typeDefs = `

type Application {
  name: String
  OARid: String
  ProdServer:String
  Connectedto (limit: Int= 10): [Application] @relation(name: "MQ", direction: IN)
}

`;

这是qraphql模式

enter image description here

谢谢!

0 个答案:

没有答案