Closed dnafication closed 2 years ago
Thanks for reporting this. I'm new to Serverless and can confirm this occurs using your same Environment config.
Downgrading to 6.6.0
works until there is a proper fix
Facing the same issue. But noticed that it actually works on first request. Second request fails with the same error.
offline: [HTTP] server ready: http://localhost:5005 🚀
offline:
offline: Enter "rp" to replay the last request
offline: POST /dev/graphql (λ: graphql)
coming HEREEE
offline: (λ: graphql) RequestId: ckew97vmt0002ptfe3xg55akb Duration: 292.22 ms Billed Duration: 300 ms
offline: POST /dev/graphql (λ: graphql)
offline: Failure: Query was defined in resolvers, but it's not an object
Error: Query was defined in resolvers, but it's not an object
I'm having the same issue 😭
When this is resolved would be really curious to see what the issue was - stumped me for a bit! Thought I had a sneaky syntax error lurking or some weird setup 😓 😄
I was able to track down a few more details about this error.
The error is raised by the graphql-tools
package. Specifically this bit of code runs differently between the first request and subsequent ones:
function getFieldsForType(type) {
if (type instanceof graphql_1.GraphQLObjectType ||
type instanceof graphql_1.GraphQLInterfaceType) {
return type.getFields();
}
else {
return undefined;
}
}
Adding some logging to the top of this function:
console.log(
'getFieldsForType',
type,
type.constructor,
type instanceof graphql_1.GraphQLObjectType,
type instanceof graphql_1.GraphQLInterfaceType
)
I was able to see this for the first run:
getFieldsForType Query [Function: GraphQLObjectType] true false
And this for subsequent:
getFieldsForType Query [Function: GraphQLObjectType] false false
It reminds be a bit of issues I've had in the past when there's multiple versions of the graphql
package in the same project and so instanceof
checks would fail when comparing a schema from one of the graphql packages to the types in the other. But I've verified there's definitely only one instance of it in my project.
I'm using serverless-plugin-typescript
as well in case it's relevant.
Reverting to 6.6.0
works for me.
I got a similar issue, allowCache: true
solved my problem.
in my severless.yml file:
custom:
serverless-offline:
allowCache: true
I think severless-offline reloaded some packages, (but not all)
so for the first time, the instanceof is fine, but the second time, the constructor is reloaded and become a new one...
That's why the instanceof
failed.
But haven't trace into severless-offline to find out why.
Bug Report
Current Behavior
Using the latest version of
serverless-offline
(6.7) withapollo-server-lambda
is resulting in an error.Ref: https://github.com/apollographql/apollo-server/issues/4519
Sample Code
Basic handler example from apollo server docs
Expected behavior/code
It used to run perfectly with
sls offline start
Environment
serverless
version: 1.80serverless-offline
version: 6.7.0node.js
version: 12.16OS
: macOSoptional, if you are using any of the following frameworks to invoke handlers
python
version: [e.g. v3.8.0]ruby
version: [e.g. v2.6.5]Possible Solution
Additional context/Screenshots