Execution fails with NRE when using generic field definition
See original GitHub issueDescription
I’m defining model with a similar field in several types. E.g.
let WidgetsField name (getUser: ResolveFieldContext -> 'a -> User) =
let resolve ctx xx =
let user = getUser ctx xx
let widgets = user.Widgets |> List.toArray
Connection.ofArray widgets
Define.Field(name, ConnectionOf Widget, "A person's collection of widgets", Connection.allArgs, resolve)
which is instantiated as
fields = [
Define.GlobalIdField(fun _ w -> w.Id)
Define.Field("name", String, fun _ w -> w.Name)
WidgetsField "widgets" (fun _ user -> user)
]
The issue is that only the first “widgets” field is functioning. All other instances causes exception in runtime.
Repro steps
Attaching modifed server.fsx for relay-starter-kit sample project.
- Put this server.fsx to the sample’s folder.
- Start the server by
fsi server.fsx
. - Run the query (in Postman)
- Start the server by
{"query": "{
viewer {name}, widgets { edges }
}"}
Notice the first declared “widgets” field is fully functional.
Actual behavior
NRE exception is raised.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
No error when using generic class without defining a type
At an assignment to a field: if the type of the left-hand operand is a raw type, then a compile-time unchecked warning occurs...
Read more >Restrictions on Generics (The Java™ Tutorials ...
To use Java generics effectively, you must consider the following restrictions: Cannot Instantiate Generic Types with Primitive Types; Cannot Create Instances ...
Read more >Using Generics as Autowiring Qualifiers
Assuming that the preceding beans implement a generic interface, (that is, Store<String> and Store<Integer> ), you can @Autowire the Store ...
Read more >Static fields should not be used in generic types
A static field in a generic type is not shared among instances of different closed constructed types, thus LengthLimitedSingletonCollection<int>.instances ...
Read more >Java Programming Tutorial on Generics
JDK 5 introduces generics, which supports abstraction over types (or parameterized types) on classes and methods. The class or method designers can be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@OlegZee @Horusiath
Until we investigate further, below is a workaround for that issue.
This is fixed with the change made in #101