0

Hello i'm trying to fetch some data in my mongoDB collections through graphQL,

Here's my graphQl schema :

type Account {
  _id: String
  id: String
  account_id: Int
  limit: Int!
  products: [String]
}

type Query {
  account(_id: String): [Account]
}

Here's a console log of the resolver return

[ { _id: 5ca4bbc7a2dd94ee58162a49,
    account_id: 142442,
    limit: 9000,
    products:
     [ 'Commodity',
       'CurrencyService',
       'Derivatives',
       'InvestmentFund',
       'InvestmentStock' ],
    id: '5ca4bbc7a2dd94ee58162a49' } ]

but here's the query returns from graphiQL

{
  "data": {
    "account": [
      {
        "id": "5ca4bbc7a2dd94ee58162a49",
        "_id": "5ca4bbc7a2dd94ee58162a49",
        "account_id": null,
        "limit": 9000,
        "products": null
      }
    ]
  }
}

I can't figure out why my products and account_id fields return a null value, they seems to have the correct type, did i miss something ?

1 Answer 1

1

Okay nevermind the problem was in the mongoose schema i forgot to add these fields

const accounts = new Schema({
    limit: Number,
    products: [String],
    account_id: Number
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.