Skip to content

Commit 437e11b

Browse files
committed
Removed unnecessary GraphQL types upcasts
1 parent b8f94ba commit 437e11b

4 files changed

Lines changed: 20 additions & 23 deletions

File tree

src/FSharp.Data.GraphQL.Server.Relay/Connections.fs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ type SliceInfo<'Cursor> =
114114

115115
[<AutoOpen>]
116116
module Definitions =
117-
let inline private nullableOutput (innerDef : #OutputDef<'Val>) : OutputDef<'Val option> =
118-
Nullable (innerDef :> OutputDef<'Val>)
119117

120118
/// <summary>
121119
/// Active pattern that extracts Relay pagination arguments from a GraphQL field context.
@@ -161,13 +159,13 @@ module Definitions =
161159
)
162160
Define.AsyncField (
163161
"startCursor",
164-
nullableOutput StringType,
162+
Nullable StringType,
165163
"When paginating backwards, the cursor to continue.",
166164
fun _ pageInfo -> pageInfo.StartCursor
167165
)
168166
Define.AsyncField (
169167
"endCursor",
170-
nullableOutput StringType,
168+
Nullable StringType,
171169
"When paginating forwards, the cursor to continue.",
172170
fun _ pageInfo -> pageInfo.EndCursor
173171
)
@@ -227,7 +225,7 @@ module Definitions =
227225
fields = [
228226
Define.AsyncField (
229227
"totalCount",
230-
nullableOutput IntType,
228+
Nullable IntType,
231229
"""A count of the total number of objects in this connection, ignoring pagination. This allows a client to fetch the first five objects by passing \"5\" as the argument to `first`, then fetch the total count so it could display \"5 of 83\", for example. In cases where we employ infinite scrolling or don't have an exact count of entries, this field will return `null`.""",
232230
fun _ conn -> conn.TotalCount
233231
)
@@ -278,8 +276,6 @@ module Edge =
278276

279277
[<RequireQualifiedAccess>]
280278
module Connection =
281-
let inline private nullableInput (innerDef : #InputDef<'Val>) : InputDef<'Val option> =
282-
Nullable (innerDef :> InputDef<'Val>)
283279

284280
/// <summary>
285281
/// Transforms a <see cref="Connection{T}"/> into a <see cref="Connection{U}"/>
@@ -308,8 +304,8 @@ module Connection =
308304
/// <seealso cref="backwardArgs"/>
309305
/// <seealso cref="allArgs"/>
310306
let forwardArgs =
311-
[ Define.Input ("first", nullableInput IntType)
312-
Define.Input ("after", nullableInput StringType) ]
307+
[ Define.Input ("first", Nullable IntType)
308+
Define.Input ("after", Nullable StringType) ]
313309

314310
/// <summary>
315311
/// Argument definitions for backward pagination ("last" and "before").
@@ -318,8 +314,8 @@ module Connection =
318314
/// <seealso cref="forwardArgs"/>
319315
/// <seealso cref="allArgs"/>
320316
let backwardArgs =
321-
[ Define.Input ("last", nullableInput IntType)
322-
Define.Input ("before", nullableInput StringType) ]
317+
[ Define.Input ("last", Nullable IntType)
318+
Define.Input ("before", Nullable StringType) ]
323319

324320
/// <summary>
325321
/// Complete set of argument definitions for bidirectional pagination.

src/FSharp.Data.GraphQL.Server/Schema.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ type SchemaConfig =
152152
let args = [|
153153
Define.Input(
154154
"interval",
155-
Nullable (IntType :> InputDef<int>),
155+
Nullable IntType,
156156
defaultValue = streamOptions.Interval,
157157
description = "An optional argument used to buffer stream results. " +
158158
"When it's value is greater than zero, stream results will be buffered for milliseconds equal to the value, then sent to the client. " +
159159
"After that, starts buffering again until all results are streamed.")
160160
Define.Input(
161161
"preferredBatchSize",
162-
Nullable (IntType :> InputDef<int>),
162+
Nullable IntType,
163163
defaultValue = streamOptions.PreferredBatchSize,
164164
description = "An optional argument used to buffer stream results. " +
165165
"When it's value is greater than zero, stream results will be buffered until item count reaches this value, then sent to the client. " +

src/FSharp.Data.GraphQL.Shared/Introspection.fs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ let rec __Type =
9090
fieldsFn =
9191
fun () -> [
9292
Define.Field ("kind", __TypeKind, (fun _ t -> t.Kind))
93-
Define.Field ("name", Nullable (StringType :> OutputDef<string>), resolve = (fun _ t -> t.Name))
94-
Define.Field ("description", Nullable (StringType :> OutputDef<string>), resolve = (fun _ t -> t.Description))
93+
Define.Field ("name", Nullable StringType, resolve = (fun _ t -> t.Name))
94+
Define.Field ("description", Nullable StringType, resolve = (fun _ t -> t.Description))
9595
Define.Field (
9696
"fields",
9797
Nullable (ListOf __Field),
@@ -173,9 +173,9 @@ and __InputValue =
173173
fieldsFn =
174174
fun () -> [
175175
Define.Field ("name", StringType, resolve = (fun _ f -> f.Name))
176-
Define.Field ("description", Nullable (StringType :> OutputDef<string>), resolve = (fun _ f -> f.Description))
176+
Define.Field ("description", Nullable StringType, resolve = (fun _ f -> f.Description))
177177
Define.Field ("type", __Type, resolve = (fun _ f -> f.Type))
178-
Define.Field ("defaultValue", Nullable (StringType :> OutputDef<string>), (fun _ f -> f.DefaultValue))
178+
Define.Field ("defaultValue", Nullable StringType, (fun _ f -> f.DefaultValue))
179179
]
180180
)
181181

@@ -189,11 +189,11 @@ and __Field =
189189
fieldsFn =
190190
fun () -> [
191191
Define.Field ("name", StringType, (fun _ f -> f.Name))
192-
Define.Field ("description", Nullable (StringType :> OutputDef<string>), (fun _ f -> f.Description))
192+
Define.Field ("description", Nullable StringType, (fun _ f -> f.Description))
193193
Define.Field ("args", ListOf __InputValue, (fun _ f -> f.Args))
194194
Define.Field ("type", __Type, (fun _ f -> f.Type))
195195
Define.Field ("isDeprecated", BooleanType, resolve = (fun _ f -> f.IsDeprecated))
196-
Define.Field ("deprecationReason", Nullable (StringType :> OutputDef<string>), (fun _ f -> f.DeprecationReason))
196+
Define.Field ("deprecationReason", Nullable StringType, (fun _ f -> f.DeprecationReason))
197197
]
198198
)
199199

@@ -208,9 +208,9 @@ and __EnumValue =
208208
fieldsFn =
209209
fun () -> [
210210
Define.Field ("name", StringType, resolve = (fun _ e -> e.Name))
211-
Define.Field ("description", Nullable (StringType :> OutputDef<string>), resolve = (fun _ e -> e.Description))
211+
Define.Field ("description", Nullable StringType, resolve = (fun _ e -> e.Description))
212212
Define.Field ("isDeprecated", BooleanType, resolve = (fun _ e -> Option.isSome e.DeprecationReason))
213-
Define.Field ("deprecationReason", Nullable (StringType :> OutputDef<string>), resolve = (fun _ e -> e.DeprecationReason))
213+
Define.Field ("deprecationReason", Nullable StringType, resolve = (fun _ e -> e.DeprecationReason))
214214
]
215215
)
216216

@@ -231,8 +231,8 @@ and __Directive =
231231
fieldsFn =
232232
fun () -> [
233233
Define.Field ("name", StringType, resolve = (fun _ directive -> directive.Name))
234-
Define.Field ("description", Nullable (StringType :> OutputDef<string>), resolve = (fun _ directive -> directive.Description))
235-
Define.Field ("locations", ListOf (__DirectiveLocation :> OutputDef<DirectiveLocation>), resolve = (fun _ directive -> directive.Locations))
234+
Define.Field ("description", Nullable StringType, resolve = (fun _ directive -> directive.Description))
235+
Define.Field ("locations", ListOf __DirectiveLocation, resolve = (fun _ directive -> directive.Locations))
236236
Define.Field ("args", ListOf __InputValue, resolve = (fun _ directive -> directive.Args))
237237
Define.Field (
238238
"onOperation",

src/FSharp.Data.GraphQL.Shared/SchemaDefinitions.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ module SchemaDefinitions =
393393
| InlineConstant value -> value.GetCoerceError destinationType
394394

395395
type TypeWrapperStaticDispatch =
396+
396397
static member Nullable<'Val>(innerDef : InputOutputDef<'Val>) : NullableDef<'Val> =
397398
let ofType : TypeDef<'Val> = upcast innerDef
398399
upcast { NullableDefinition.OfType = ofType }

0 commit comments

Comments
 (0)