-
Notifications
You must be signed in to change notification settings - Fork 5
Conversation
import { TestxServer } from '../src'; | ||
|
||
async function startServer(model: string) { | ||
const server = new TestxServer({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to assign a port instead of having one randomly generated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+100.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The server start() method should be already abel to accpet a custom port, and if not is very easy to do it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wtrocki if you can take do something like port = argv.port || '4001'
and then call it a day
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TestxServer start is calling the GraphbackServer start function which accepts a fixed port, is just a matter of adding the argument to the TestxServer start and pass it through
graphql-testx/src/TestxServer.ts
Line 101 in db2a503
await this.server.start(); |
graphql-testx/src/GraphbackServer.ts
Line 32 in db2a503
public async start(port?: number): Promise<void> { |
const modelLocation = argv.model as string; | ||
if (existsSync(modelLocation)) { | ||
const fileContent = readFileSync(modelLocation, { encoding: 'utf8' }); | ||
startServer(fileContent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
startServer(fileContent); | |
startServer(fileContent).catch(e => throw e); |
an alternative would be to log the error and stack and then exit with something different from 0, the only problem with the current way is that nodejs will give an error like not handled exception in promise
which is not so nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the best approach will be to create a main
function
async function main() {
// everything here
}
main().catch(e => {throw e});
@wtrocki this is really great |
This is just example what we can do. I do not intent to merge it here. |
if (argv.model) { | ||
const modelLocation = argv.model as string; | ||
if (existsSync(modelLocation)) { | ||
const fileContent = readFileSync(modelLocation, { encoding: 'utf8' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about moving the file read part inside Testx itself?
#97
Add very basic cli that will help us to run server using model file