Papercut: duplicate type names do not cause an error when building a Schema object
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- fsharp
- Domain
- api
Research direction
Start at Schema(schemaType), using the Define.Object and Executor entry points shown in the reproduction. Trace how the schema collects named types and determine where duplicate names are accepted. Done means constructing the schema fails for the two Book definitions, with the reproduction or a focused validation check confirming the error occurs before execution.
Written by the indexing model from the issue text.
Description
This script demonstrates the issue:
#r "nuget: FSharp.Data.GraphQL.Server, 1.0.7"
open FSharp.Data.GraphQL
open FSharp.Data.GraphQL.Execution
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",
String,
fun ctx (x : Book) -> x.Title
)
]
)
let bookType2 =
Define.Object(
name = "Book",
description = "Book type 2",
fields =
[
Define.Field(
"title",
String,
fun ctx (x : Book) -> x.Title
)
Define.Field(
"year",
Int,
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
| x -> failwith $"Unsupported: %A{x}"
printfn $"Output:\n%A{output}\n"
for error in errors do
printfn $"Error:\n%A{error}\n"
Output:
map []
Error:
("Field 'year' is not defined in schema type 'Book'.", ["books2"; "year"])
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.
let schema = Schema(schemaType) // Should raise an exception on an invalid schema
Any thoughts?
- Dominant language
- F#
- Stars
- 406
- Forks
- 74
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 14
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fsprojects/FSharp.Data.GraphQL
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
fsprojects/FSharp.Data.GraphQL#573 · 1 reaction · 2 assignees ·
-
FR: Suave package Open
fsprojects/FSharp.Data.GraphQL#566 · 1 comment · 1 reaction · 2 assignees ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
All issues in fsprojects/FSharp.Data.GraphQL
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
avniproject/avni-client#2135 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
use-agent-os/agent-os#3276 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
good first issue refactor
Difficulty 2/5 1-3 hours Newbie friendliness 72/100