“Apollo GraphQL” Código de respuesta

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 Ejemplo

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

Respuestas similares a “Apollo GraphQL”

Preguntas similares a “Apollo GraphQL”

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código