graphql-testx
graphql-testx copied to clipboard
Add the option to load the type model definition from file
It would be nice if it could be possible to do something like this:
new TestxServer(path.resolve(__dirname, 'schema.graphql'))
but because both the model definition and the file path are strings, in my opinion, something like this is more clear:
new TestxServer({file: path.resolve(__dirname, 'schema.graphql')})
or we could expose a helper method:
testxServerFromFile(path.resolve(__dirname, 'schema.graphql'))
@b1zzu I really like this feature, we can try to do something like constructor overload.
Blocked by: https://github.com/aerogear/graphql-testx/issues/103
@vinifarias I've opened a separate issue to discuss how we could improve the TestxServer constructor/api, we can move the discussion there. Btw what's a constructor overload?
@b1zzu It's when you use multiple constructors for a class, and each of them has different parameters.
@vinifarias that's not possible in typescript/javascript, the alternative in our case would be to add n optional parameters, but it has this drawback
new TestxServer("option one", undefined, undefined, undefined, undefined, "som other options")
@b1zzu Sorry XD, it's not a good idea to keep this type of constructor with many optional parameters.
@vinifarias no need to be sorry :smile:, in Java it's a good approach because it's possible to define multiple constructors with the same number of arguments
I plan to use testx with graphback that will use graphql-config.
GraphQL Config always passing compiled schema/string. Files are hard as all depends on the __dirname and process.cwd