Giter VIP home page Giter VIP logo

graphql-apollo-mongodb-example's Introduction

An example of Apollo Client/GraphQL API with MongoDB connection for NextJS app

This is a companion source code for building Apollo GraphQL API with MongoDB connection for Next.js project.

Related Articles

I've setup a step-by-step guide on how to setup the project from scratch:

[Part 1] Server-side: Setting up GraphQL API with MongoDB and Apollo Server for a NextJS app

[Part 2] Client-side: How to setup Apollo Client in order to perform GraphQL queries with NextJS

Deployed project preview

https://graphql-apollo-mongodb-example.now.sh

Getting Started

First, run the development server:

yarn dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying pages/index.js. The page auto-updates as you edit the file.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

graphql-apollo-mongodb-example's People

Contributors

alexandr-g avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

graphql-apollo-mongodb-example's Issues

Hello route was missing and how I solved

Hi Alexander,

I cloned this git repo and tried to run the app. I was following your article at https://levelup.gitconnected.com/setting-up-graphql-api-with-mongodb-and-apollo-server-for-a-nextjs-app-cec7a9baedbf

I could not get to http://localhost:3000/api/hello because hello.js was missing under ../pages/api folder.
So, I created hello.js page. Then, I found that I have to pass a query string called sayHello.
I did that as well. Now, I can get correct result at

http://localhost:3000/api/hello?{query=sayHello} as

{"data":{"sayHello":"Hello World!"}}

hello.js code I used is as follows:

`import { ApolloServer, gql } from 'apollo-server-micro'

const typeDefs = gqltype Query { sayHello: String }

const resolvers = {
Query: {
sayHello(parent, args, context) {
return 'Hello World!'
},
},
}

export const config = {
api: {
bodyParser: false,
},
}

const apolloServer = new ApolloServer({ typeDefs, resolvers })
export default apolloServer.createHandler({ path: '/api/hello' })`

I thought I would share my findings with you so that you can commit the changes if you want to make this article in sync with git repo. One minor typo - Vie should read as Via in the paragraph titled Configuring .env variables.

Thanks,

Sunil

apollo/client upgrade 3.1.1 -cache issues

I tried upgrading this sample project to "@apollo/client": "3.1.1", for some reason, caching does not seem to work ,it is always making a network query instead of getting the cache in 3.1.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.