Skip to content

Latest commit

 

History

History
102 lines (74 loc) · 4.13 KB

README.md

File metadata and controls

102 lines (74 loc) · 4.13 KB

⚡ 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