New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
schema first from multiple files #2109
Comments
anyone can help ? |
If you define the same type in multiple files, you have to add a.graphql: type Query{
hello: String!
} b.graphql: extend type Query{
hi: String!
} More details about this : https://www.apollographql.com/blog/modularizing-your-graphql-schema-code-d7f71d5ed5f2 |
Thanks for reply. |
I think you have another issue. This following code works: class Program
{
static void Main(string[] args)
{
var sb = SchemaBuilder.New().AddDocumentFromFile("a.graphql")
.AddDocumentFromFile("b.graphql")
.AddResolver("Query", "hi", "Earth")
.AddResolver("Query", "hello", "World")
.Create();
var r = sb.MakeExecutable().Execute("{ hi\nhello\n }");
Console.WriteLine(r.ToJson());
}
} Result: {
"data": {
"hi": "Earth",
"hello": "World"
}
} Can you please share more code or create a github repo with your code? |
We haven’t support for extend on sdl first yet. There is however a big update coming to sdl first. We will soon start discussing sdl first in v11 |
Join our slack channel |
Closing this issue since splitting types in sdl first is not supported in 10 |
Is it supported for v11? |
I tried to split graqhql language code in multiple files like this:
a.graphql:
type Query{
hello: String!
}
b.graphql:
type Query{
hi: String!
}
and typed code like this in gateway, but i get an error
" HotChocolate.SchemaException:“The name
Query
was already registered by another type. - Type: Query":services.AddGraphQL(sp => SchemaBuilder.New()
.AddDocumentFromFile("a.graphql")
.AddDocumentFromFile("b.graphql")
.BindComplexType()
.Create());
The text was updated successfully, but these errors were encountered: