1

Consider the following subscription for apollo:

 entityCreated: {
      subscribe: withFilter(
        () => pubsub.asyncIterator(["ENTITY_CREATED"]),
        async (payload, variables, context) => {
          let result = await firebaseApi.userHasEntity(
            context.user,
            payload.entityCreated
          );
          // Prints true 
          console.log(result);
          return result;
        }
      ),
    },

I'm using codegen listener to listen for this event but it only triggers when this function is as follows:

  entityCreated: {
    subscribe: withFilter(
      () => pubsub.asyncIterator(["ENTITY_CREATED"]),
      async (payload, variables, context) => {
        return true;
      }
    ),
  },

And with the second this works perfectly. Why? It seems like the first variant doesn't wait for the async call to complete?

Christo S. Christov
  • 2,268
  • 3
  • 32
  • 57

0 Answers0