开发者

How to connect my gRPC server written in java with graphQL server

开发者 https://www.devze.com 2022-12-07 21:34 出处:网络
I have a simple graphQL server import { ApolloServer } from "@apollo/server"; import { startStandaloneServer } from "@apollo/server/standalone";

I have a simple graphQL server

import { ApolloServer } from "@apollo/server";
import { startStandaloneServer } from "@apollo/server/standalone";

const typeDefs = `#graphql
type Task {
    id: String
  name: String
  completed: Boolean
}

type Query {
  tasks: [Task]
}
`;

const tasks = [
  { id: "todo-1", name: "Eat", completed: true },
  { id: "todo-2", name: "Sleep", completed: false },
  { id: "todo-3", name: "Repeat", completed: false },
];

const resolvers = {
  Query: {
    tasks: () => tasks,
  },
};

const server = new ApolloServer({
  typeDefs,
  resolvers,
});

const { url } = await startStandaloneServer(server, {
  listen: { port: 4002 },
});

console.log(`
0

精彩评论

暂无评论...
验证码 换一张
取 消