Closed mununki closed 2 years ago
Good catch! I'll fix this and put out a new test package you can try. Let me get back to you once I have done that.
@mattdamon108 can you try 0.0.0-connection-id-maker-fix-389056d3
?
Can you explain how to install it? It doesn't seem the branch name.
Just setting the version in package.json to that should work, ie "rescript-relay": "0.0.0-connection-id-maker-fix-389056d3"
It seems fixed! But I have another issue with the connection. My schema is like
module Fragment = %relay(`
fragment UpdateProductOptionsAdminFragment on Product {
id
displayName
...ProductSummaryAdminFragment
... on NormalProduct {
isCourierAvailable
productOptions(first: 20)
@connection(key: "UpdateProductOptionsAdmin_productOptions") {
__id
edges {
node {
id
status
...UpdateProductOptionAdminFragment
}
}
}
}
... on QuotableProduct {
isCourierAvailable
productOptions(first: 20)
@connection(key: "UpdateProductOptionsAdmin_productOptions") {
__id
edges {
node {
id
status
...UpdateProductOptionAdminFragment
}
}
}
}
}
`)
The value getConnectionNodes can't be found in UpdateProductOptionsAdminFragment_graphql
is thrown. I've read the doc https://rescript-relay-documentation.vercel.app/docs/mutations#updating-connections, but makeConnectionId
function signature is different from the doc.
Got it, I know what the problem is. Let me think a bit on how to solve it best.
@mattdamon108 could you paste the contents of that generated file? UpdateProductOptionsAdminFragment_graphql
.
Sorry, I'm late 😄
/* @sourceLoc Update_ProductOptions_Admin.res */
/* @generated */
%%raw("/* @generated */")
module Types = {
@@ocaml.warning("-30")
type rec fragment_productOptions_edges_node = {
@live id: string,
status: RelaySchemaAssets_graphql.enum_ProductOptionStatus,
fragmentRefs: RescriptRelay.fragmentRefs<[ | #UpdateProductOptionAdminFragment]>,
}
and fragment_productOptions_edges = {
node: fragment_productOptions_edges_node,
}
and fragment_productOptions = {
@live __id: RescriptRelay.dataId,
edges: array<fragment_productOptions_edges>,
}
type fragment = {
@live __typename: string,
displayName: string,
@live id: string,
isCourierAvailable: option<bool>,
productOptions: option<fragment_productOptions>,
fragmentRefs: RescriptRelay.fragmentRefs<[ | #ProductSummaryAdminFragment]>,
}
}
module Internal = {
@live
type fragmentRaw
@live
let fragmentConverter: Js.Dict.t<Js.Dict.t<Js.Dict.t<string>>> = %raw(
json`{"__root":{"productOptions_edges_node":{"f":""},"":{"f":""}}}`
)
@live
let fragmentConverterMap = ()
@live
let convertFragment = v => v->RescriptRelay.convertObj(
fragmentConverter,
fragmentConverterMap,
Js.undefined
)
}
type t
type fragmentRef
external getFragmentRef:
RescriptRelay.fragmentRefs<[> | #UpdateProductOptionsAdminFragment]> => fragmentRef = "%identity"
@live
@inline
let connectionKey = "UpdateProductOptionsAdmin_productOptions"
%%private(
@live @module("relay-runtime") @scope("ConnectionHandler")
external internal_makeConnectionId: (RescriptRelay.dataId, @as("UpdateProductOptionsAdmin_productOptions") _, 'arguments) => RescriptRelay.dataId = "getConnectionID"
)
let makeConnectionId = (connectionParentDataId: RescriptRelay.dataId, ) => {
let args = ()
internal_makeConnectionId(connectionParentDataId, args)
}
module Utils = {
@@ocaml.warning("-33")
open Types
@live
external productOptionStatus_toString: RelaySchemaAssets_graphql.enum_ProductOptionStatus => string = "%identity"
@live
external productOptionStatus_input_toString: RelaySchemaAssets_graphql.enum_ProductOptionStatus_input => string = "%identity"
@live
let productOptionStatus_decode = (enum: RelaySchemaAssets_graphql.enum_ProductOptionStatus): option<RelaySchemaAssets_graphql.enum_ProductOptionStatus_input> => {
switch enum {
| #...RelaySchemaAssets_graphql.enum_ProductOptionStatus_input as valid => Some(valid)
| _ => None
}
}
@live
let productOptionStatus_fromString = (str: string): option<RelaySchemaAssets_graphql.enum_ProductOptionStatus_input> => {
productOptionStatus_decode(Obj.magic(str))
}
}
type relayOperationNode
type operationType = RescriptRelay.fragmentNode<relayOperationNode>
let node: operationType = %raw(json` (function(){
var v0 = {
"count": null,
"cursor": null,
"direction": "forward",
"path": [
"productOptions"
]
},
v1 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__typename",
"storageKey": null
},
v2 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
v3 = [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "isCourierAvailable",
"storageKey": null
},
{
"alias": "productOptions",
"args": null,
"concreteType": "ProductOptionConnection",
"kind": "LinkedField",
"name": "__UpdateProductOptionsAdmin_productOptions_connection",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "ProductOptionEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "ProductOption",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v2/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "status",
"storageKey": null
},
{
"args": null,
"kind": "FragmentSpread",
"name": "UpdateProductOptionAdminFragment"
},
(v1/*: any*/)
],
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "cursor",
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "PageInfo",
"kind": "LinkedField",
"name": "pageInfo",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "endCursor",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasNextPage",
"storageKey": null
}
],
"storageKey": null
},
{
"kind": "ClientExtension",
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__id",
"storageKey": null
}
]
}
],
"storageKey": null
}
];
return {
"argumentDefinitions": [],
"kind": "Fragment",
"metadata": {
"connection": [
(v0/*: any*/),
(v0/*: any*/)
]
},
"name": "UpdateProductOptionsAdminFragment",
"selections": [
(v1/*: any*/),
(v2/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "displayName",
"storageKey": null
},
{
"args": null,
"kind": "FragmentSpread",
"name": "ProductSummaryAdminFragment"
},
{
"kind": "InlineFragment",
"selections": (v3/*: any*/),
"type": "NormalProduct",
"abstractKey": null
},
{
"kind": "InlineFragment",
"selections": (v3/*: any*/),
"type": "QuotableProduct",
"abstractKey": null
}
],
"type": "Product",
"abstractKey": "__isProduct"
};
})() `)
I'm having trouble reproducing this. 2 things:
I think you can reproduce with https://github.com/green-labs/sinsunhi-frontend-mirror/tree/rescript-relay-test
And I'll try to make and add a test to reproduce too!
I followed the LOCAL_DEVELOPMENT.md
. But I'm afraid I can go further. Can you guide the steps how to build and test.
I'm trying to run a test in packages/rescript-relay
. Before that shouldn't I build the whole packages maybe?
Will have a look!
@mattdamon108 can you try 0.0.0-connection-id-maker-fix-24be613b
? Pretty sure that should fix it.
@zth Perfect! It compiles fine. Thank you for your prompt fix!
I face a type error in generated
makeConnectionId
function with latest1.0.0-rc.5
I guess,
onlyBuyable
argument can't be a bool type with a default valueJs.null
. I've read the changelog, but let me know if I miss something.