const { makeExecutableSchema } = require('graphql-tools'); const typeDefs = ` type Query { books: [Book] } type Book { title: String, author: String } `; const resolvers = { Query: { books: () => fetch('https://api.example.com/books') }, }; const schema = makeExecutableSchema({ typeDefs, resolvers });
A GraphQL server is a thin translation layer over your existing backends. It's easy to write one:
You can use JavaScript, as in the example here, or any language you're already familiar with.
Develop your schema with concise, declarative syntax, and fill in the logic with resolver functions.
Mock your GraphQL schema with one line of code, so you can develop your UI in parallel with the API.
Factor chunks of schema functionality into directives you can easily reuse around your schema.
Combine and remix multiple GraphQL schemas into one, as if you're using Lego blocks.
Add event-based data streaming to your GraphQL API, enabling realtime features in your app.
Apollo Server has everything you need to get performance insights and caching with Engine built in.