-
There is a simple resolver like this @InjectContext()
protected $ctx?: PlatformContext;
@Query(() => [User], { nullable: true })
async users(): Promise<Partial<User>[] | null> {
console.log(this.$ctx?.request.raw)
const users = await this.repo.user.findMany()
return users
} and we are creating a test client like this export const createTestClient = (
server: ApolloServerBase<TypeGraphQLService>
): ApolloServerTestClient => {
const executeOperation = server.executeOperation.bind(server);
const test = ({ query, mutation, ...args }: Query | Mutation) => {
const operation = query || mutation;
if (!operation || (query && mutation)) {
throw new Error(
"Either `query` or `mutation` must be passed, but not both."
);
}
return executeOperation({
// Convert ASTs, which are produced by `graphql-tag` but not currently
// used by `executeOperation`, to a String using `graphql/language/print`.
query: typeof operation === "string" ? operation : print(operation),
...args,
});
};
return { query: test, mutate: test } as ApolloServerTestClient;
}; we are using koa and tries to make request like this to this test client import "@tsed/platform-koa";
...
const GET_USERS = gql`
query {
users {
id
email
username
}
}
`;
...
request = createTestClient(apolloServer);
...
const response = await request.query({
query: GET_USERS,
variables: {},
}); But we cannot set headers for this query. How could we manage to send headers with this query and read from |
Beta Was this translation helpful? Give feedback.
Answered by
Romakita
Aug 16, 2023
Replies: 1 comment 12 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think you misunderstood where is the problem.
Ts.ED doesn't support typegraphql. It use TypeORM so any question related to graqhql should be addressed to typegraphql and not to Ts.ED itself.
I already answer you about that. I'm not responsible if you haven't looked on typegraphql to solve your issue. When you said "tsed doesn't support subscription", again you clearly misunderstood where is the graphql feature responsability 😔 (here it's typegraqhQL again)
Also, my point of view is always the same (and described in the issue guideline, but you haven't read that, because you haven't opened an issue). Create repository example, afd your expectation and I'll take a time to help you. And yo…