Skip to content

Latest commit

 

History

History
 
 

apollo-nexus-schema

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

GraphQL apollo Server with nexus schema and CURD system

This example shows how to implement a GraphQL server with TypeScript based on Prisma Client, GraphQL Nexus and @prisma-tools/nexus 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 nexus 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-nexus-schema

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-nexus-schema && move prisma-tools-master/examples/apollo-nexus-schema apollo-nexus-schema && rmdir /S /Q prisma-tools-master && del /Q master.tar.gz

Install dependencies

The project has downloaded to directory called apollo-nexus-schema

npm

Run this three commands

cd apollo-nexus-schema
npm i
npm run dev

yarn

Run this three commands

cd apollo-nexus-schema
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

The schema that specifies the API operations of your GraphQL server has defined in src/generated/schema.graphql. 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