Skip to content

📋 Node app to display data from a PostgreSQL database using Apollo-Server & GraphQL.

Notifications You must be signed in to change notification settings

AndrewJBateman/graphql-node-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ GraphQL Node Data

  • Node app to display data from a PostgreSQL database using Apollo-Server & GraphQL.
  • Note: to open web links in a new window use: ctrl+click on link

GitHub repo size GitHub pull requests GitHub Repo stars GitHub last commit

📄 Table of contents

📚 General info

  • PostgreSQL used as the database with Prisma to access it. PostgreSQL installed on Windows 10 Home. It was not possible to use MongoDB Atlas.
  • Prisma Client used: auto-generated & type-safe query builder. Prisma CRUD operations are asynchronous.

📷 Screenshots

Frontend screenshot

📶 Technologies

💾 Setup

  • Install dependencies using npm i
  • Add database URL to .env - see example.env. Database is specified in schema.prisma
  • Run node src/index.js to start app
  • After changes to prisma run npx prisma migrate dev --name "very brief summary"
  • To apply the changes and update your Prisma Client API run npx prisma generate

🔧 Testing

  • n/a

💻 Code Examples

  • /resolvers/Mutation.js nested write function to write relational data to database
async function post(parent, args, context, info) {
  const { userId } = context;

  return await context.prisma.link.create({
    data: {
      url: args.url,
      description: args.description,
      title: args.title,
      postedBy: {
        connect: {
          id: userId,
        },
      },
    },
  });
}

🆒 Features

  • GraphQL: provides a complete and understandable description of the API data. Clients can ask for exactly what they need and nothing more, saving cost on mobile data plans etc. Easier to evolve APIs over time. Enables powerful developer tools

📋 Status, Testing & To-Do List

  • Status: Working
  • To-Do: Nothing

👏 Inspiration/General Tools

📁 License

  • N/A

✉️ Contact

About

📋 Node app to display data from a PostgreSQL database using Apollo-Server & GraphQL.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published