“Apollo GraphQL” Respostas de código

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

Exemplo Apollo Graphql Clearstore

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

Respostas semelhantes a “Apollo GraphQL”

Perguntas semelhantes a “Apollo GraphQL”

Procure respostas de código populares por idioma

Procurar outros idiomas de código