Closed duncanhealy closed 4 years ago
Hey is this test-resolvers file working for you? When I run it against the testProject1 endpoint (run node index
inside testProject1 to get the endpoint spun up on localhost:3000) I get the following errors.
---->node test-resolvers.js doing Book (node:56813) UnhandledPromiseRejectionWarning: Error: Field "primaryAuthor" of type "Author" must have a selection of subfields. Did you mean "primaryAuthor { ... }"?: {"response":{"errors":[{"message":"Field \"primaryAuthor\" of type \"Author\" must have a selection of subfields. Did you mean \"primaryAuthor { ... }\"?","locations":[{"line":1,"column":130}]}],"status":400,"headers":{}},"request":{"query":"{allBooks(LIMIT:1){Books{_id title pages weight keywords editions prices isRead mongoId mongoIds authors {name,birthday,strings} primaryAuthor strArrs createdOn createdOnYearOnly jsonContent}}}"}} at GraphQLClient.
(/Users/adam.rackis/Documents/git/mongo-graphql-starter/test/testProject1/graphQL/node_modules/graphql-request/dist/src/index.js:87:35) at step (/Users/adam.rackis/Documents/git/mongo-graphql-starter/test/testProject1/graphQL/node_modules/graphql-request/dist/src/index.js:40:23) at Object.next (/Users/adam.rackis/Documents/git/mongo-graphql-starter/test/testProject1/graphQL/node_modules/graphql-request/dist/src/index.js:21:53) at fulfilled (/Users/adam.rackis/Documents/git/mongo-graphql-starter/test/testProject1/graphQL/node_modules/graphql-request/dist/src/index.js:12:58) at processTicksAndRejections (internal/process/task_queues.js:93:5) (node:56813) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:56813) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Hi only got to look at this today - Yes same error - I've add a check for isObject as well as isArray and it add the nested fields, I've commented out the mutations as they need a more involved generation step
test steps
# npm install run-rs -g
run-rs -v 4.0.12
node test/testProject1
AUTH_TOKEN="" GRAPHQL_URL=http://localhost:3000/graphql node test/testProject1/index-test.js
Did those steps really work for you? testProject1/index-test.js
doesn't exist for me. I changed it to testProject1/graphQL/test-resolvers.js
, then removed the esm import for graphql-request in favor of CJS require, then did an npm init and npm install for graphql-request, and then it failed on fetch
not being defined. Do you have some sort of Node fetch polyfill installed globally?
Also, can you help me understand the value of these tests? It appears to just run run each query, and request each field, without doing any kind of verification on the data that come back (there shouldn't be any data). This seems like a subset of what the unit / integration tests I already have.
the index-test was the same esm loader - added there
the fetch polyfill is required for graphql-request > v2 - 1.8.2 worked fine prisma-labs/graphql-request/#127
The tests on your testProjects are not required as you cover them already but they are useful for someone using the library to generate their own tests
if we could generate a set of tests as complete as yours given a SDL spec that would be the goal
Oh sorry - forgot about this. Will test the latest updates soon.
Ok - merging this. I don't think this feature is quite complete. It seems like a smell that you need a fetch polyfill, and the tests don't appear too useful, but since it's not documented, and the generated file isn't really hurting anything, I'm happy to put it in since you seem to have some use for it.
64 fix circular ref for mutations