-
Notifications
You must be signed in to change notification settings - Fork 73
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
Papercut: duplicate type names do not cause an error when building a Schema object #454
Comments
Is it on NuGet release package or in GitHub CI package? |
This is NuGet |
Try package from GitHub, it may be fixed there |
Is there any reason the latest is not pushed to NuGet? |
There are 2 important PRs left to merge |
Please review them and give your opinion |
Still an issue: #r "nuget: FSharp.Data.GraphQL.Server, 2.2.1"
open FSharp.Data.GraphQL
open FSharp.Data.GraphQL.Types
type Book =
{
Title : string
Year : int
}
let bookType1 =
Define.Object(
name = "Book",
description = "Book type 1",
fields =
[
Define.Field(
"title",
StringType,
fun ctx (x : Book) -> x.Title
)
]
)
let bookType2 =
Define.Object(
name = "Book",
description = "Book type 2",
fields =
[
Define.Field(
"title",
StringType,
fun ctx (x : Book) -> x.Title
)
Define.Field(
"year",
IntType,
fun ctx (x : Book) -> x.Year
)
]
)
let schemaType : ObjectDef<unit> =
Define.Object(
name = "Query",
fields =
[
Define.Field(
"books1",
ListOf bookType1,
fun _ () -> []
)
Define.Field(
"books2",
ListOf bookType2,
fun _ () -> []
)
]
)
let schema = Schema(schemaType)
let executor = Executor(schema)
let query = """
{
books2 {
title
year
}
}
"""
let result =
executor.AsyncExecute (query)
|> Async.RunSynchronously
let output, errors =
match result.Content with
| GQLResponseContent.Direct (output, errors) -> output, errors
| GQLResponseContent.RequestError errors -> dict [], errors
| x -> failwith $"Unsupported: %A{x}"
printfn $"Output:\n%A{output}\n"
for error in errors do
printfn $"Error:\n%A{error}\n"
|
2.2.1 does not contain the fix try with such
|
We do testing of the latest 3.0.0 changes on our project and almost came to release |
@njlr currently the logic is such FSharp.Data.GraphQL/src/FSharp.Data.GraphQL.Shared/TypeSystem.fs Lines 1905 to 1911 in 434b4be
FSharp.Data.GraphQL/src/FSharp.Data.GraphQL.Server.Middleware/MiddlewareDefinitions.fs Lines 68 to 82 in 434b4be
FSharp.Data.GraphQL/src/FSharp.Data.GraphQL.Server.Middleware/MiddlewareDefinitions.fs Line 81 in 434b4be
How would you suggest to change that? |
This script demonstrates the issue:
The two book types share a name, and the library silently picks
bookType1
.I think that duplicate names should cause schema building to fail, so that this error is caught earlier.
Any thoughts?
The text was updated successfully, but these errors were encountered: