Skip to content

Latest commit

 

History

History
 
 

apollo-sdl-first

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

GraphQL apollo Server with sdl first and CURD system

This example shows how to implement a GraphQL server with TypeScript based on Prisma Client and @prisma-tools/sdl to create CURD system. It is based on a SQLite database, you can find the database file with some dummy data at ./prisma/dev.db.

How to use

Download starter project

This guide uses a small starter project that has Prisma configured against a SQLite database file.

Open your terminal and download the starter project with the following command:

Unix (Mac OS, Linux)

curl https://codeload.github.com/AhmedElywa/prisma-tools/tar.gz/master | tar -xz --strip=2 prisma-tools-master/examples/apollo-sdl-first

Windows

curl https://codeload.github.com/AhmedElywa/prisma-tools/tar.gz/master -o master.tar.gz && tar -zxvf master.tar.gz prisma-tools-master/examples/apollo-sdl-first && move prisma-tools-master/examples/apollo-sdl-first apollo-sdl-first && rmdir /S /Q prisma-tools-master && del /Q master.tar.gz

Install dependencies

The project has downloaded to directory called apollo-sdl-first

npm

Run this three commands

cd apollo-sdl-first
npm i
npm run dev

yarn

Run this three commands

cd apollo-sdl-first
yarn
yarn dev

Navigate to http://localhost:4000 in your browser to explore the API of your GraphQL server in a GraphQL Playground.

Using the GraphQL API

Below are a number of operations that you can send to the API using the GraphQL Playground.

Feel free to adjust any operation by adding or removing fields. The GraphQL Playground helps you with its auto-completion and query validation features.

Retrieve all users and their posts

{
  findManyUser {
    id
    email
    name
    posts {
      id
      title
      published
      comments {
        id
        contain
      }
    }
  }
}

Have questions?

Didn't find something here? Look through the issues or simply drop us a line at ahmed.elywa@icloud.com.

Like my tool give me star