Graphql-yoga: Can't change default port for server

Created on 26 Apr 2018  路  5Comments  路  Source: dotansimha/graphql-yoga

@darmie commented on Wed Apr 25 2018

Bug Report

Current behavior
Prisma app server not running on set port
Reproduction
Simply change NODE_PORT value in .env file
Expected behavior?
Server should run on set port


@marktani commented on Thu Apr 26 2018

Hey @darmie, thanks for bringing this up.

With "Prisma app server", do you refer to graphql-yoga?
Can you show a code snippet that show cases the wrong behaviour?


@darmie commented on Thu Apr 26 2018

@marktani yes the issue is with graphql-yoga

port is set in .env

...
NODE_PORT= 4000
...

And the index.ts code is the default

const server = new GraphQLServer({
  typeDefs: './src/schema.graphql',
  resolvers,
  context: req => ({
    ...req,
    db: new Prisma({
      endpoint: process.env.PRISMA_ENDPOINT, // the endpoint of the Prisma DB service (value is set in .env)
      secret: process.env.PRISMA_SECRET, // taken from database/prisma.yml (value is set in .env)
      debug: true, // log all GraphQL queries & mutations
    }),
  }),
})

server.start({port: process.env.NODE_PORT})
console.log("Prisma app is now running on http://localhost"+process.env.NODE_PORT)

if I change the value of NODE_PORT, Playground will launch but server is not working.

kinquestion statupr-welcome

Most helpful comment

still problem emerged for me today. yoga version 1.16.7. setting port to whatever value but only runs on port 4000.

EDIT: I passed port to the constructor and not the start method. Perhaps throwing an error or a warning when unknown args are passed to constructor

All 5 comments

Any news ? This bug can be annoying especially for testing.

I don't have any problem with yoga 1.8.5, strange :o .

@kMeillet for testing, use port: 0! :)

It gives you a random available port, allows you to parallelise your tests too - example in src/index.test.ts

Awesome ! Thanks for the trick.

Seems like this is solved now. Thanks @KATT for explaining!

still problem emerged for me today. yoga version 1.16.7. setting port to whatever value but only runs on port 4000.

EDIT: I passed port to the constructor and not the start method. Perhaps throwing an error or a warning when unknown args are passed to constructor

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ahmedosama5200 picture ahmedosama5200  路  4Comments

woss picture woss  路  5Comments

asci picture asci  路  3Comments

kv-pawar picture kv-pawar  路  3Comments

playerx picture playerx  路  5Comments