godon019
5/6/2019 - 1:35 AM

prisma server connection test from graphql-yoga(backend)

const server = new GraphQLServer({
  typeDefs: './src/schema.graphql',
  resolvers,
  context: request => ({
    ...request,
    // prisma,
    prisma
  }),
  // middlewares: [logInput, logResult],
})
server.start((options) => {
  console.log(`Server is running on...${JSON.stringify(options, null, 2)}`)
  console.log('App secrect', process.env.APP_SECRET)
  console.log(`prisma local endpoint: ${process.env.PRISMA_LOCAL_ENDPOINT}`)
  // console.log(`prisma remote(aws_fargate..deprecated) endpoint: ${process.env.PRISMA_AWS_FARGATE_ENDPOINT}`)
  console.log(`prisma demo endpoint: ${process.env.PRISMA_DEMO_ENDPOINT}`)
  
  //Prisma connection test by querying existing user
  const userAlias = process.env.TEST_USER_ALIAS
  console.log(`Prisma server connection test: query user with alias "${userAlias}"`)
  prisma.$exists.user({alias: userAlias}).then((result)=>{
    console.log(`user with alias "${userAlias}" exists? ${result}`)
  })
})

when I see the bottom server.start() there are

  //Prisma connection test by querying existing user
  const userAlias = process.env.TEST_USER_ALIAS
  console.log(`Prisma server connection test: query user with alias "${userAlias}"`)
  prisma.$exists.user({alias: userAlias}).then((result)=>{
    console.log(`user with alias "${userAlias}" exists? ${result}`)
  })

this line is good for prisma testing(the user is already seeded by defalt)