Skip to content

naotake51/chat-compo-graphql-server

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Description

Nest framework TypeScript starter repository.

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

Query sample

GraphQL Playground http://localhost:3000/graphql

HTTP HEADERS

{
  "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InRlc3RAZXhhbXBsZS5jb20iLCJzdWIiOiI4Njc0MmNkNy02MDhhLWYzNzItZTRlNy1lZjBhMmVhMjNmYzciLCJpYXQiOjE2NjI0NDg0MjQsImV4cCI6MTY2MjQ1MjAyNH0.m0nLK9XGuXArn-v3vsbCXPXzgr3QnL5cUkZMTu9Gn3M"  
}

Login Developer

mutation {
  login(
    loginInput: {
      email: "[email protected]", 
      password: "password12345"
    }
  ) {
    developer {
    	email
      joinedProducts {
        productId
  	  	product {
          id
        }
      }
    },
    accessToken
  }
}

Show Developer

query {
  developer(id: "86742cd7-608a-f372-e4e7-ef0a2ea23fc7") {
    id
    email
    joinedProducts {
      productId
  		product {
        id
      }
    }
  }
  talker(id: "1") {
    id
    name
    joinedRooms {
      joinedMessageOrder
      readMessageOrder
      room {
       id
       name
       joinedTalkers {
         joinedMessageOrder
         readMessageOrder
      	 talker {
          id
         }
       }
     }
    }
  }
}

Create Developer

mutation {
  createDeveloper(
    data: {
      email: "[email protected]"
      password: "password1234"
    }
  ) {
    email
  }
}

Update Developer

mutation {
  updateDeveloper(
    data: {
      id: "86742cd7-608a-f372-e4e7-ef0a2ea23fc7", 
      email: "[email protected]"
    }
  ) {
    email
  }
}

Subscribe Developer Update

subscription {
  developerUpdated(id: "86742cd7-608a-f372-e4e7-ef0a2ea23fc7") {
    id
    email
  }
}

DataBase

npx prisma studio

http://localhost:5555

Seeder

npx prisma db seed

Environment

Properties defined in .env are merged into environment variables.

.env

NODE_ENV="development"

Once you have defined the new environment variables, add the code to the following file.

src/global.d.ts

declare namespace NodeJS {
  interface ProcessEnv {
    readonly NODE_ENV: 'development' | 'production' | 'test';
  }
}

src/app.module.ts

@Module({
  imports: [
    ConfigModule.forRoot({
      validationSchema: Joi.object({
        NODE_ENV: Joi.string()
          .valid('development', 'production', 'test')
          .required(),
      }),
    }),

Create Test DB & Migration

docker-compose exec postgres psql -U root -d chat-compo -c "CREATE DATABASE \"chat-compo-test\""

Prism references .env, so copy .env.test to .env and run the command.

npx prisma migrate deploy

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published