-
Notifications
You must be signed in to change notification settings - Fork 74
Added tests for reserved scalar names handling #550
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,3 +1,6 @@ | ||||||
| ### 3.1.1 - 2026-04-03 | ||||||
| * Fixed GraphQL client provider handling for schema types that reuse reserved scalar names such as `Date`, so introspection kind now takes precedence over built-in scalar mappings. | ||||||
|
|
||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this must go to the bottom of the file |
||||||
| #### 0.0.1-beta - 2016-04-19 | ||||||
| * Initial release | ||||||
|
|
||||||
|
|
@@ -242,4 +245,4 @@ | |||||
|
|
||||||
| ### 3.1.1 - Unreleased | ||||||
|
||||||
| ### 3.1.1 - Unreleased | |
| ### 3.1.2 - Unreleased |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -297,10 +297,6 @@ module internal ProvidedOperation = | |||||
| tdef.AddXmlDoc("Represents a GraphQL operation on the server.") | ||||||
| tdef.AddMembersDelayed(fun _ -> | ||||||
| let operationResultDef = ProvidedOperationResult.makeProvidedType(operationType) | ||||||
| let isScalar (typeName: string) = | ||||||
| match schemaTypes.TryFind typeName with | ||||||
| | Some introspectionType -> introspectionType.Kind = TypeKind.SCALAR | ||||||
| | None -> false | ||||||
| let variables = | ||||||
| let rec mapVariable (variableName : string) (variableType : InputType) = | ||||||
| match variableType with | ||||||
|
|
@@ -309,9 +305,9 @@ module internal ProvidedOperation = | |||||
| | Some uploadInputTypeName when typeName = uploadInputTypeName -> | ||||||
| struct (variableName, typeName, TypeMapping.makeOption typeof<Upload>) | ||||||
| | _ -> | ||||||
| match TypeMapping.scalar.TryFind(typeName) with | ||||||
| match TypeMapping.tryFindScalarType schemaTypes typeName with | ||||||
| | Some t -> struct (variableName,typeName, TypeMapping.makeOption t) | ||||||
| | None when isScalar typeName -> struct (variableName, typeName, typeof<string option>) | ||||||
| | None when TypeMapping.isScalarTypeName schemaTypes typeName -> struct (variableName, typeName, typeof<string option>) | ||||||
| | None -> | ||||||
| match schemaProvidedTypes.TryFind(typeName) with | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| | Some t -> struct (variableName, typeName, TypeMapping.makeOption t) | ||||||
|
|
@@ -381,7 +377,7 @@ module internal ProvidedOperation = | |||||
| tdef.DeclaredProperties |> Seq.exists ((fun p -> p.PropertyType) >> existsUploadType) | ||||||
| variables |> Seq.exists (fun struct (_, _, t) -> existsUploadType t) | ||||||
| || variables | ||||||
| |> Seq.where (fun struct (_, typeName, _) -> TypeMapping.scalar.TryGetValue typeName |> fst |> not) | ||||||
| |> Seq.where (fun struct (_, typeName, _) -> not (TypeMapping.isScalarTypeName schemaTypes typeName)) | ||||||
| |> Seq.choose (fun struct (_, typeName, _) -> schemaProvidedTypes |> Map.tryFind typeName) | ||||||
| |> Seq.exists existsUploadTypeDefinition | ||||||
| let runMethodOverloads : MemberInfo list = | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,50 @@ | ||||||||||||||||||||||
| module FSharp.Data.GraphQL.IntegrationTests.ReservedScalarNameProviderTests | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| open Xunit | ||||||||||||||||||||||
| open Helpers | ||||||||||||||||||||||
| open FSharp.Data.GraphQL | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| type ObjectDateProvider = GraphQLProvider<"reserved_scalar_object_date_introspection.json"> | ||||||||||||||||||||||
| type InputDateProvider = GraphQLProvider<"reserved_scalar_input_date_introspection.json"> | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| module ObjectDateSchema = | ||||||||||||||||||||||
| type SchemaDate = ObjectDateProvider.Types.Date | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| let operation = | ||||||||||||||||||||||
| ObjectDateProvider.Operation<"""query Q { | ||||||||||||||||||||||
| dateInfo { | ||||||||||||||||||||||
| value | ||||||||||||||||||||||
| category | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| }""">() | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| let compileSmoke () = | ||||||||||||||||||||||
| let schemaDate = SchemaDate(value = "2026-04-03", category = "default") | ||||||||||||||||||||||
| let operationInstance : ObjectDateProvider.Operations.Q = operation | ||||||||||||||||||||||
| schemaDate |> ignore | ||||||||||||||||||||||
| operationInstance |> ignore | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| module InputDateSchema = | ||||||||||||||||||||||
| type SchemaDate = InputDateProvider.Types.Date | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| let operation = | ||||||||||||||||||||||
| InputDateProvider.Operation<"""query Q($input: Date) { | ||||||||||||||||||||||
| echoDate(input: $input) | ||||||||||||||||||||||
| }""">() | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| let compileSmoke () = | ||||||||||||||||||||||
| let schemaDate = SchemaDate(value = "2026-04-03", category = "default") | ||||||||||||||||||||||
| let deferredRun : unit -> _ = | ||||||||||||||||||||||
| fun () -> operation.Run(Unchecked.defaultof<GraphQLProviderRuntimeContext>, schemaDate) | ||||||||||||||||||||||
| schemaDate |> ignore | ||||||||||||||||||||||
| deferredRun |> ignore | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| [<Fact>] | ||||||||||||||||||||||
| let ``Should allow object types that reuse reserved scalar names`` () = | ||||||||||||||||||||||
| ObjectDateSchema.compileSmoke () | ||||||||||||||||||||||
| true |> equals true | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| [<Fact>] | ||||||||||||||||||||||
| let ``Should allow input object types that reuse reserved scalar names`` () = | ||||||||||||||||||||||
| InputDateSchema.compileSmoke () | ||||||||||||||||||||||
| true |> equals true | ||||||||||||||||||||||
|
||||||||||||||||||||||
| true |> equals true | |
| [<Fact>] | |
| let ``Should allow input object types that reuse reserved scalar names`` () = | |
| InputDateSchema.compileSmoke () | |
| true |> equals true | |
| [<Fact>] | |
| let ``Should allow input object types that reuse reserved scalar names`` () = | |
| InputDateSchema.compileSmoke () |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| { | ||
| "data": { | ||
| "__schema": { | ||
| "queryType": { | ||
| "name": "Query" | ||
| }, | ||
| "mutationType": null, | ||
| "subscriptionType": null, | ||
| "types": [ | ||
| { | ||
| "kind": "SCALAR", | ||
| "name": "String", | ||
| "description": null, | ||
| "fields": null, | ||
| "inputFields": null, | ||
| "interfaces": null, | ||
| "enumValues": null, | ||
| "possibleTypes": null | ||
| }, | ||
| { | ||
| "kind": "OBJECT", | ||
| "name": "Query", | ||
| "description": null, | ||
| "fields": [ | ||
| { | ||
| "name": "echoDate", | ||
| "description": null, | ||
| "args": [ | ||
| { | ||
| "name": "input", | ||
| "description": null, | ||
| "type": { | ||
| "kind": "INPUT_OBJECT", | ||
| "name": "Date", | ||
| "ofType": null | ||
| }, | ||
| "defaultValue": null | ||
| } | ||
| ], | ||
| "type": { | ||
| "kind": "SCALAR", | ||
| "name": "String", | ||
| "ofType": null | ||
| }, | ||
| "isDeprecated": false, | ||
| "deprecationReason": null | ||
| } | ||
| ], | ||
| "inputFields": null, | ||
| "interfaces": [], | ||
| "enumValues": null, | ||
| "possibleTypes": null | ||
| }, | ||
| { | ||
| "kind": "INPUT_OBJECT", | ||
| "name": "Date", | ||
| "description": null, | ||
| "fields": null, | ||
| "inputFields": [ | ||
| { | ||
| "name": "value", | ||
| "description": null, | ||
| "type": { | ||
| "kind": "SCALAR", | ||
| "name": "String", | ||
| "ofType": null | ||
| }, | ||
| "defaultValue": null | ||
| }, | ||
| { | ||
| "name": "category", | ||
| "description": null, | ||
| "type": { | ||
| "kind": "SCALAR", | ||
| "name": "String", | ||
| "ofType": null | ||
| }, | ||
| "defaultValue": null | ||
| } | ||
| ], | ||
| "interfaces": null, | ||
| "enumValues": null, | ||
| "possibleTypes": null | ||
| } | ||
| ], | ||
| "directives": [] | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| { | ||
| "data": { | ||
| "__schema": { | ||
| "queryType": { | ||
| "name": "Query" | ||
| }, | ||
| "mutationType": null, | ||
| "subscriptionType": null, | ||
| "types": [ | ||
| { | ||
| "kind": "SCALAR", | ||
| "name": "String", | ||
| "description": null, | ||
| "fields": null, | ||
| "inputFields": null, | ||
| "interfaces": null, | ||
| "enumValues": null, | ||
| "possibleTypes": null | ||
| }, | ||
| { | ||
| "kind": "OBJECT", | ||
| "name": "Query", | ||
| "description": null, | ||
| "fields": [ | ||
| { | ||
| "name": "dateInfo", | ||
| "description": null, | ||
| "args": [], | ||
| "type": { | ||
| "kind": "OBJECT", | ||
| "name": "Date", | ||
| "ofType": null | ||
| }, | ||
| "isDeprecated": false, | ||
| "deprecationReason": null | ||
| } | ||
| ], | ||
| "inputFields": null, | ||
| "interfaces": [], | ||
| "enumValues": null, | ||
| "possibleTypes": null | ||
| }, | ||
| { | ||
| "kind": "OBJECT", | ||
| "name": "Date", | ||
| "description": null, | ||
| "fields": [ | ||
| { | ||
| "name": "value", | ||
| "description": null, | ||
| "args": [], | ||
| "type": { | ||
| "kind": "SCALAR", | ||
| "name": "String", | ||
| "ofType": null | ||
| }, | ||
| "isDeprecated": false, | ||
| "deprecationReason": null | ||
| }, | ||
| { | ||
| "name": "category", | ||
| "description": null, | ||
| "args": [], | ||
| "type": { | ||
| "kind": "SCALAR", | ||
| "name": "String", | ||
| "ofType": null | ||
| }, | ||
| "isDeprecated": false, | ||
| "deprecationReason": null | ||
| } | ||
| ], | ||
| "inputFields": null, | ||
| "interfaces": [], | ||
| "enumValues": null, | ||
| "possibleTypes": null | ||
| } | ||
| ], | ||
| "directives": [] | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The release notes now contain two separate sections for version 3.1.1 (one dated and one 'Unreleased'), which is confusing and can lead to incorrect changelog generation. Please merge these entries under a single 3.1.1 section, or bump the 'Unreleased' header to the next version (e.g., 3.1.2 - Unreleased) so each version appears only once.