Open V1os opened 1 year ago
Please create a PR with a failing test case. I can't guess from your snippets what's wrong with your apollo server, federation or server configuration.
@V1os
Have you added the correct TypeScript compiler options as shown in TypeGraphQL's documentation.
Due to using the graphql-subscription
dependency that relies on an AsyncIterator
, we may also have to provide the esnext.asynciterable to the lib
option:
{
"compilerOptions": {
"target": "es2018",
"module": "commonjs",
"lib": ["es2018", "esnext.asynciterable"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}
@carlocorradini hi. Yee, i provided needs options ts
, but i think that it is some little thing, which is hard to see at first sight.
@V1os Can you share the project or a failing example?
@carlocorradini I think how to do it ... for now, at most, this is the general view of the server and resolver. By the way, i builded scheme for federation service
@V1os Federation version 1 or version 2?
2
Found the issue, Federation 2 requires graphql >= 16
while TypeGraphQL
requires graphql < 16
. You can follow TypeGraphQL v2.0
with support for a newer version of graphql
in this pull request.
If you really want to use Apollo Federation V2
you must have a separate package with graphql >= 16
and then import it in your main project with graphql < 16
. If you don't do something crazy, it works flawlessly. Take a look at my example here.
@carlocorradini tnx bro, i will write about the status.
@V1os Can we close this issue? 🥳
Yep, there is a reason in version graphql
package. Thank you
though, this is not version (
i take 15.8.0
, from example, but still not working
Did you created a different project with graphql > = 16
(different package.json
) and imported in main project with graphql < 16
it is a lerna workspace (subscription service) with his package, and graphql@15.8.0
Unfortunately, without the code or a minimal example, I can't determine what the cause could be.
I experience a variant of this issue. My error message is:
Error: Subscription field must return Async Iterable. Received: null
It happens when there's at least 1h uninterupted connection between client and server I reported it in graphql-ws ( https://github.com/enisdenjo/graphql-ws/issues/418 ) but seems more appropriate here?
This error happens to me when my authChecker
returns false
for the subscription. I want to hide the error (since it's not an error that an unauthorized subscription is blocked) but can't figure out where to do that...
Workaround for authChecker
issue:
Instead of returning false
in the authChecker
callback, throw an error directly when auth fails (inside the authChecker
callback). This prevents the irrelevant subscription error.
Edit: oof, this leaks stack traces to the frontend though 😕
I have my resolvers (and schema) separated by small files. In the case of resolvers, they are javascript files, with a final export default resolvers;, and that's the line I had forgotten.
I'll show the code just in case:
import { pubSub, names } from '~/src/config/subscriptions';
import { EzfacilityClientBooking } from '~/src/repositories';
const resolvers = {
Subscription: {
clientBookingsChanged: {
subscribe: () => {
const asyncIterator = pubSub.asyncIterator([names.CLIENT_BOOKINGS_CHANGED]);
// Fetch immediately the data from EZ
const clientBooking = new EzfacilityClientBooking();
clientBooking.getAll();
return asyncIterator;
}
}
}
};
export default resolvers;
@dev-bhargav7 Is this a TypeGraphQL code?
Describe the Bug Error after subscription client.
To Reproduce
Expected Behavior After execution of subscription operation on Studio ApolloGraphql sandbox, i expect to connect to the socket, and receive messages on the emission of events. But get the error subscribe
Logs
Environment (please complete the following information):
Additional Context Add any other context about the problem here.