yahoohung / loopback-graphql-server

Combine the powers of GraphQL with the backend of Loopback to automatically generate GraphQL endpoints based on Loopback Schema.
MIT License
84 stars 25 forks source link

belongsTo relation returns null #19

Open SilvaLA59 opened 5 years ago

SilvaLA59 commented 5 years ago

Hello, I'm trying do make a query with relation. I can get the correct result from hasMany relation but when I try with a belongsTo relation the return is null, see Solicitante and TipoDespesa. Does anyone can see what I'm doing wrong? When I call the find method on loopback explorer with these relation I can get all the informations. Query

{
  Solicitacao{
    SolicitacaoFind(
      filter: {
        where: { Codigo: 4},
        include: ["Solicitante", "SolicitacaoItens"]
      }
      options: {}) {
      edges {
        node {
      Codigo,
          Solicitante {
            username,
            email
          }
          SolicitacaoItens {
            edges {
              node {
                CodigoTipoSolicitacaoItem,
                QuantidadeComprovantes,
                TipoDespesa {
                  Codigo,
                  Descricao,
                  CodigoSAP
                }
              }
            }
          }
        }
      }
    }
  }
}

Result

{
  "data": {
    "Solicitacao": {
      "SolicitacaoFind": {
        "edges": [
          {
            "node": {
              "Codigo": 4,
              "Solicitante": null,
              "SolicitacaoItens": {
                "edges": [
                  {
                    "node": {
                      "CodigoTipoSolicitacaoItem": 9,
                      "QuantidadeComprovantes": 150,
                      "TipoDespesa": null
                    }
                  },
                  {
                    "node": {
                      "CodigoTipoSolicitacaoItem": 4,
                      "QuantidadeComprovantes": 105,
                      "TipoDespesa": null
                    }
                  },
                  {
                    "node": {
                      "CodigoTipoSolicitacaoItem": 9,
                      "QuantidadeComprovantes": 300,
                      "TipoDespesa": null
                    }
                  }
                ]
              }
            }
          }
        ]
      }
    }
  }
}
techuila commented 5 years ago

Did you solved your issue?

SilvaLA59 commented 5 years ago

Did you solved your issue?

No. Actually I gave up on loopback-graphql

techuila commented 5 years ago

I also gave up on it. I used express - graphql now.

Milos5611 commented 4 years ago

@SilvaLA59 @techuila can someone pls share did you manage to get GraphQL work in Loopback successfully and in production? And how. Thanks in advance guys

techuila commented 4 years ago

I can't remember what were the issues I encountered using loopback, but all I remember is I switched to express and graphql and didn't encounter any issues further on.