V8-archive: Getting a empty array with graphql from a M2M relationship but not from M2O

Created on 24 Sep 2019  Â·  8Comments  Â·  Source: directus/v8-archive

Bug Report

Steps to Reproduce

I'm testing the database from Directus in postman with graphql.

  1. Create 2 Collections (, let's name them Test3 and Test4) with ID, name and SKU fields.
  2. Create a test_junction Collection, which is hidden, and two numeric fields (test3 & test4)
  3. Go to Test3 and create a M2M field with the test name 'tree'. Under the "relation" tab, declare Test4 as my related Collection and test_junction as my junction Collection. ID from Test3 goes into test3 and the ID from Test4 into test4.
  4. As visible columns add name and sku, allow create and allow select, save.
  5. Create in both Collections some test items/products (4), with unique names, SKUs for a obvious separation between the products.
  6. Go to the products from Test3 and add under the "tree" field some products from Test4.
  7. Go to Postman, get the token to be allowed to get data from the database/directus.
  8. Open a new tab and choose "POST" and type next it the https link from your directus +/_/gql
  9. Click the "Authorization" tab, choose Bearer Token as type and paste your token in.
  10. Click on the "Body" tab and insert the code and press send:

query{ test3{ data{ name sku tree{ name sku } } } }
Screenshot 2019-09-24 at 10 50 03

Expected Behavior

To get the same result with a M2O relationship:
{ "data": { "test3": { "data": [ { "name": "T-Shirt", "sku": "12", "tree": { "name": "T-Shirt T1", "sku": "1236" } } ... ] } } }

Actual Behavior

I get an empty Array even though on Directus I get displayed that the two products are linked trough the M2M relationship. I have the same problem with a O2M relation but not with a M2O, though it's the "same relationship"

{ "data": { "test3": { "data": [ { "name": "T-Shirt", "sku": "12", "tree": [] } ... ] } } }

Technical Details

  • Device: [MacBook Pro]
  • OS: [MacOS 10.14.6]
  • Web Server: [nginx/1.14.0 (Ubuntu)]
  • Database: [MySQL 5.7]
  • Install Method: [cloned origin/master branch]
bug

Most helpful comment

Any Open tickets are being worked on, or will be worked on. And these new duplicates are referenced there too... so even this ticket gives us more context. :)

All 8 comments

Thanks for the comprehensive ticket, @joshuabush — would you happen to have a SQL schema that we can more quickly test with? If it has any sensitive data you can share with us on Slack:

https://directus.chat

I did some testing, so i hope you wont get confused.
My names for them are Item3 and Item4 , but I have the same problem with products and simpleproducts
basestacca-mg1-live.sql.zip

I have the same issue with an O2M relation.

I'm using a somewhat more exotic stack with Amazon Aurora and Docker, but I don't think any of that causes the issue. I'm willing to do some investigating, but could you help me get started? Maybe some logs I can check or flags to enable.

{
  persons {
    data {
      name,
      affiliations {
        id
      }
    }
  }
}

Returns

{
  "data": {
    "persons": {
      "data": [
        {
          "name": "Klaus Iohannis",
          "affiliations": []
        }
      ]
    }
  }
}

But Klaus has 2 affiliations in my database.

EDIT: Tested on a more traditional LAMP stack and got the same result.

duplicate issue with #1167

Why is it closed?
You didn't gave me a solution how to fix it
@bjgajjar

@joshuabush - It is duplicate of #1167. So I closed this issue. You will get your solution when the #1167 will be resolved :)

Okay sorry, I just thought because the user of the issue #1167 didn't answered you wouldn't consider to work further on that problem, because of the lack of information.
Thanks again! ^^

Any Open tickets are being worked on, or will be worked on. And these new duplicates are referenced there too... so even this ticket gives us more context. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cdwmhcc picture cdwmhcc  Â·  3Comments

binary-koan picture binary-koan  Â·  3Comments

gitlabisbetterthangithub picture gitlabisbetterthangithub  Â·  3Comments

Nitwel picture Nitwel  Â·  3Comments

magikstm picture magikstm  Â·  3Comments