“Apollo Graphql” Code-Antworten

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 Beispiel

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

Ähnliche Antworten wie “Apollo Graphql”

Fragen ähnlich wie “Apollo Graphql”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen