defradb icon indicating copy to clipboard operation
defradb copied to clipboard

One sided primary relations are not queryable

Open AndrewSisley opened this issue 7 months ago • 1 comments

Found by David, e.g.: ######### Schema

type TypeA {
  test: String
}

type TypeB {
  test: String
  ref: TypeA @primary
}

######### Create Types

mutation create_typeA {
  create_TypeA(input: { test: "1" }) {
    _docID
  } # bae-31fc529a-4edb-54e3-bf44-439a6570daf4
}
mutation create_typeB {
  create_TypeB(
    input: { test: "2", ref_id: "bae-31fc529a-4edb-54e3-bf44-439a6570daf4" }
  ) {
    _docID
  } # bae-b7a8d5ee-375d-5d90-90a6-f518fed888b2
}

######### Query

query { TypeB { test ref { test } } }

######### Result

{
  "data": null,
  "errors": [
    "The given field does not exist. Name: ref"
  ]
}

The schema is valid (although I'm not sure we test with the primary directive), as one-sided relations are fairly new it might be that we never actually test querying them and have relied on introspection/collection-description tests.

AndrewSisley avatar Jul 11 '24 19:07 AndrewSisley