Query resolver gets called multiple times (2) per single request #5647
-
I'm using type-graphql and Apollo, the client makes 1 POST request with the graphql query and my backend runs the resolver 2 times. This is not my main concern, although I'd like to know why, but the thing is that only the last of the 2 times it gets the cookies, which are essential to determine if the client is authorized to view the content or not. @Resolver(ContentModel)
export class ContentSchemaResolver {
@Query(() => ContentModel, { nullable: true })
async content(@Ctx() context: HttpContext, @Arg('id', () => ID) id: string) {
const content = await ContentModel.findOne(id);
// [...]
return content;
}
// [...]
} PS: Should I paste more code? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes, if you want help debugging you'll need to provide a full reproduction example. Ideally something that starts with Resolvers should run multiple times if the field is used more than once. Also I have no idea what your |
Beta Was this translation helpful? Give feedback.
Yes, if you want help debugging you'll need to provide a full reproduction example. Ideally something that starts with
git clone
or uses codesandbox.io. Also include the operation you are running, etc.Resolvers should run multiple times if the field is used more than once. Also I have no idea what your
@Resolver
and@Query
annotations are; might be relevant.