So I never found the answer online but decided I should post this in case someone else runs into this issue.
First you need to setup the context that'll be used
const schema = await buildSchema({
resolvers: [
YourResolver
]
});
const apolloServer = new ApolloServer({
schema,
context: ({ req }) => {
// this will return something you can pick up using @Ctx("param")
const someValue: string = req.headers["some-value"] as string;
var obj = {
value: someValue
};
return obj;
}
});
Second you need to reference it
@Query(() => string, { nullable: true })
async Get (
@Ctx("value") val: string
): Promise<string> {
return new Promise<string>((res:any) => { res(value); });
}
Works in Query, Mutations, and FieldResolvers. No param should return the whole object, haven't tested it.