“Apollo GraphQL” Kode Jawaban

Apollo GraphQL

const { ApolloServer, gql } = require("apollo-server");

//Define your GraphQL schema
const typeDefs = gql`
  type Book {
    title: String
    author: String
  }
  type Query {
    books: [Book]
  }
  // NOTE: please do not use any colon " : " or " , "
`;

  //Define your data set
const books = [
  {
    title: "The Awakening",
    author: "Kate Chopin",
  },
  {
    title: "City of Glass",
    author: "Paul Auster",
  },
];

//Define a resolver
const resolvers = {
  Query: {
    books: () => {
      return [books];
    },
  },
};

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

server.listen().then(({ url }) => {
  console.log(`server ready at ${url}`);
});
Azizul7m

Apollo Graphql Clearstore Contoh

await client.clearStore()
await persistor.purge()
Embarrassed Echidna

Jawaban yang mirip dengan “Apollo GraphQL”

Pertanyaan yang mirip dengan “Apollo GraphQL”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya