Coder Social home page Coder Social logo

Graphql queries work incorrect about strapi HOT 8 CLOSED

strapi avatar strapi commented on May 29, 2024
Graphql queries work incorrect

from strapi.

Comments (8)

kulakowka avatar kulakowka commented on May 29, 2024

I noticed a very strange behavior. Sometimes it works correctly. Sometimes not. I was unable to understand the reason.

from strapi.

Aurelsicoko avatar Aurelsicoko commented on May 29, 2024

Which Waterline adapter are you using? I think the problem comes from Waterline... Sometimes it seems the values are not populated in the response object.

from strapi.

kulakowka avatar kulakowka commented on May 29, 2024

@Aurelsicoko i'm using sails-mongo, but there is a possibility that it is buggy at the default settings.

I will try to create a new application, without any additional adapters. I'll let you know about the results here.

from strapi.

kulakowka avatar kulakowka commented on May 29, 2024

I tested it on a new application. Here's what happens:

Standard API gives data correctly.

http://localhost:1337/article

[  
   {  
      "contributors":[  
         {  
            "username":"kulakowka",
            "email":"[email protected]",
            "lang":"en_US",
            "template":"default",
            "id_ref":"1",
            "provider":"local",
            "id":1,
            "createdAt":"2016-01-31T23:19:54.227Z",
            "updatedAt":"2016-01-31T23:19:54.237Z"
         }
      ],
      "comments":[  
         {  
            "content":"Comment 1 for article 1",
            "lang":"en_US",
            "template":"default",
            "createdBy":1,
            "updatedBy":1,
            "article":1,
            "id":1,
            "createdAt":"2016-01-31T23:21:16.614Z",
            "updatedAt":"2016-01-31T23:21:29.139Z"
         },
         {  
            "content":"Comment 2 for article 1",
            "lang":"en_US",
            "template":"default",
            "createdBy":1,
            "updatedBy":1,
            "article":1,
            "id":2,
            "createdAt":"2016-01-31T23:21:31.371Z",
            "updatedAt":"2016-01-31T23:21:39.347Z"
         }
      ],
      "createdBy":{  
         "username":"kulakowka",
         "email":"[email protected]",
         "lang":"en_US",
         "template":"default",
         "id_ref":"1",
         "provider":"local",
         "id":1,
         "createdAt":"2016-01-31T23:19:54.227Z",
         "updatedAt":"2016-01-31T23:19:54.237Z"
      },
      "updatedBy":{  
         "username":"kulakowka",
         "email":"[email protected]",
         "lang":"en_US",
         "template":"default",
         "id_ref":"1",
         "provider":"local",
         "id":1,
         "createdAt":"2016-01-31T23:19:54.227Z",
         "updatedAt":"2016-01-31T23:19:54.237Z"
      },
      "title":"Article 1",
      "content":"Test for article 1",
      "lang":"en_US",
      "template":"default",
      "id":1,
      "createdAt":"2016-01-31T23:19:59.536Z",
      "updatedAt":"2016-01-31T23:20:10.032Z"
   },
   {  
      "contributors":[  
         {  
            "username":"kulakowka",
            "email":"[email protected]",
            "lang":"en_US",
            "template":"default",
            "id_ref":"1",
            "provider":"local",
            "id":1,
            "createdAt":"2016-01-31T23:19:54.227Z",
            "updatedAt":"2016-01-31T23:19:54.237Z"
         }
      ],
      "comments":[  
         {  
            "content":"Comment 1 for article 2",
            "lang":"en_US",
            "template":"default",
            "createdBy":1,
            "updatedBy":1,
            "article":2,
            "id":3,
            "createdAt":"2016-01-31T23:21:41.160Z",
            "updatedAt":"2016-01-31T23:21:52.418Z"
         },
         {  
            "content":"Comment 2 for article 2",
            "lang":"en_US",
            "template":"default",
            "createdBy":1,
            "updatedBy":1,
            "article":2,
            "id":4,
            "createdAt":"2016-01-31T23:21:54.028Z",
            "updatedAt":"2016-01-31T23:22:03.647Z"
         }
      ],
      "createdBy":{  
         "username":"kulakowka",
         "email":"[email protected]",
         "lang":"en_US",
         "template":"default",
         "id_ref":"1",
         "provider":"local",
         "id":1,
         "createdAt":"2016-01-31T23:19:54.227Z",
         "updatedAt":"2016-01-31T23:19:54.237Z"
      },
      "updatedBy":{  
         "username":"kulakowka",
         "email":"[email protected]",
         "lang":"en_US",
         "template":"default",
         "id_ref":"1",
         "provider":"local",
         "id":1,
         "createdAt":"2016-01-31T23:19:54.227Z",
         "updatedAt":"2016-01-31T23:19:54.237Z"
      },
      "title":"Article 2",
      "content":"Text for article 2",
      "lang":"en_US",
      "template":"default",
      "id":2,
      "createdAt":"2016-01-31T23:20:11.033Z",
      "updatedAt":"2016-01-31T23:20:19.405Z"
   }
]

But graphql response has wrong data:

http://localhost:1337/graphql?query={articles{id,title,createdBy{id,username},comments{id,content}}}

{  
   "data":{  
      "articles":[  
         {  
            "id":"1",
            "title":"Article 1",
            "createdBy":{  
               "id":"1",
               "username":"kulakowka"
            },
            "comments":[  
               {  
                  "id":"1",
                  "content":"Comment 1 for article 1"
               },
               {  
                  "id":"2",
                  "content":"Comment 2 for article 1"
               },
               {  
                  "id":"3",
                  "content":"Comment 1 for article 2"
               },
               {  
                  "id":"4",
                  "content":"Comment 2 for article 2"
               }
            ]
         },
         {  
            "id":"2",
            "title":"Article 2",
            "createdBy":null,
            "comments":[  
               {  
                  "id":"1",
                  "content":"Comment 1 for article 1"
               },
               {  
                  "id":"2",
                  "content":"Comment 2 for article 1"
               },
               {  
                  "id":"3",
                  "content":"Comment 1 for article 2"
               },
               {  
                  "id":"4",
                  "content":"Comment 2 for article 2"
               }
            ]
         }
      ]
   }
}

I did not make any settings other than the relationship between the models.

Maybe I'm wrong to set up a relationship between the models?

2016-02-01 2 32 22

2016-02-01 2 33 49

from strapi.

Aurelsicoko avatar Aurelsicoko commented on May 29, 2024

No, your relationships look good. I will take a look at it tomorrow There is an issue but it's strange because we didn't notice this before. The GraphQL support has not been updated for 2 months.

from strapi.

kulakowka avatar kulakowka commented on May 29, 2024

I found something strange. Take a look at the screenshot:

2

1

I do not know whether it is right or not. But it looks strange.

Perhaps this is a bug in the admin panel?

When I switch on the fields Relations

2016-02-01 3 06 34

Preview looks like this

2016-02-01 3 07 20

Then I switch to a different field

2016-02-01 3 07 59

Preview looks like this

2016-02-01 3 08 42

Nothing but the name does not change. Although it is obvious that the scheme should be changed.

from strapi.

Aurelsicoko avatar Aurelsicoko commented on May 29, 2024

Fixed! I had the same behavior. Thanks for your detailed feedback.

from strapi.

kulakowka avatar kulakowka commented on May 29, 2024

I'm glad to help you.

from strapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.