-
|
Hey everyone, I am trying to setup GiraphQL while having the following file structure:
And then I have a import builder from "../builder";
builder.queryType({
fields: (t) => ({
hello: t.string({
args: {
name: t.arg.string(),
},
resolve: (parent, { name }) => `hello, ${name || "World"}`,
}),
}),
});However, I expected that the builder would pick this query up while it is in a different file. But unfortunately, the actual schema stays empty and GraphiQL obviously gives me the following error: {
"errors": [
{
"message": "Query root type must be provided."
}
]
}Which makes sense, since the schema is empty. Is there another way to make sure that I could create queries and mutations in different files and make sure that those will get picked up by the builder and in a schema. I am just trying GiraphQL out and I might be doing something wrong, I think that this should work though. Let me know if I am missing something. Thanks a lot! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
You just need to import the files that define your types before you call .toSchema. I usually have a schema.ts file that imports all my files that define types, then have that file export the built schema |
Beta Was this translation helpful? Give feedback.
You just need to import the files that define your types before you call .toSchema. I usually have a schema.ts file that imports all my files that define types, then have that file export the built schema