[ ] Regression
[ ] Bug report
[ ] Feature request
[*] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
always null

return data
note.graphql
type Note {
title:String
type:String
status:String
updatetime:String
top:String
noteid:Int
userid:Int
}
type List {
list:[Note]
total:Int!
}
type Query {
notes:List
note(userid:String):Note
}
resolver
import {
Resolver,
Query,
Args,
} from "@nestjs/graphql";
import { NoteService } from "./note.service";
@Resolver("Note")
export class NoteResolver {
constructor(
private readonly noteService: NoteService,
) { }
@Query("notes")
public notes() {
return {
list: [{
title: "1",
type: "1",
status: "1",
updatetime: "1",
top: "1",
noteid: 1,
userid: 1,
}],
total: 1,
};
}
@Query("note")
public note(@Args("userid") userid: string) {
console.log(userid);
return {
title: "1",
type: "1",
status: "1",
updatetime: "1",
top: "1",
noteid: 1,
userid,
};
}
}
Nest version: 5.3.11
For Tooling issues:
- Node version: 8.11.4
- Platform: Windows
Others:
@kamilmysliwiec please help me and thank you.
@rgolea
@printjs have you imported the resolver? Are you printing the anything on your console?
@rgolea
Yes,I have imported the resolver like below.
@Module({
controllers: [NoteController],
providers: [NoteService, NoteResolver],
exports: [NoteService],
})
export class NoteModule {}
I debug the program.I found request that com from 127.0.0.1:19985/graphaql into breakpointer and the program can print userid
I am facing this same problem right now.
I fixed my case. VSCode auto-imports imported the Query decorator from @nestjs/common rather than @nestjs/graphql.
Thank you but query come from @nestjs/graphql in my program @CDDelta
@printjs can you share with me the code? I can look and see if I can help.
@rgolea thank you. My project in https://github.com/printjs/graphql_ts and you just run npm i & npm run start. next step is visit localhost:3000/graphql
thank you very much.
@printjs this is weird... mine prints... Try reinstalling the project and updating your node version and your typescript version.

@rgolea I'm so sorry.I give you wrong address.
Sorry, wasted your time.
The correct address is https://github.com/printjs/corgicherry.
You can run npm i & npm run start and visit http://127.0.0.1:19885/graphql
the graphql file is src/graphql/note/note.gql and the resolver file is note.resolver.ts in src/modules/notes/note.resolver.ts
I'm so sorry for give you wrong address.
I resolve the problem.Due to the interception change the data struct.
sorry not that im ranting, i was also a victim of wrong imports in vscode and i spent 3-4 hours scratching my head trying to figure out the problem. i think at least an effort to improve the nestjs/graphql docs and add a warning section about this problem would prevent someone encountering this
If someone has trouble with no executing Query, check if your modules don't have the same name. This situation may lead to null return.
In my case this was because I was only doing include: [WorkspacesModule] in GraphQL configuration. You actually need to import the module twice like:
@Module({
imports: [
WorkspacesModule,
GraphQLModule.forRoot({
typePaths: ['./**/*.graphql'],
include: [WorkspacesModule],
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
I fixed my case. VSCode auto-imports imported the
Querydecorator from@nestjs/commonrather than@nestjs/graphql.