Closed spyalert01 closed 8 years ago
The GraphQL schema defines your contract with a client of your GraphQL api. This schema is not necessary the same as your database(s) schema (if any).
You'll want to use the resolve
function that you specify in your GraphQL objects fields to (for example) query your datasource and return the data you need.
GraphQL is database/datasource agnostic so there is no "preferred" db.
(all of this is afaik)
1) Do you have a simple working example that have GraphQL and Mongo in the schema? I came accross the graffiti, but I am looking for a more straight forward way to do it.
2) as per your mention, GraphQL is database. So where does GraphQL keep data? example I call mongo a database because there is a place to keep data in a storage,
I do not have a working Mongo example. You might want to try to fork the example here https://github.com/graphql/express-graphql and add Mongo as the data layer to start understanding how it could work in your case.
I said that GraphQL is database/datasource agnostic meaning that for GraphQL it does not mater what kind of database you use to retrieve the data (if any).
GraphQL is a REST replacement not a new type of DB. On Tue, Aug 25, 2015 at 9:20 AM Nicola Peduzzi notifications@github.com wrote:
I do not have a working Mongo example. You might want to try to fork the example here https://github.com/graphql/express-graphql and add Mongo as the data layer to start understanding how it could work in your case.
I said that GraphQL is database/datasource agnostic meaning that for GraphQL it does not mater what kind of database you use to retrieve the data (if any).
— Reply to this email directly or view it on GitHub https://github.com/graphql/graphql-js/issues/148#issuecomment-134657663.
@spyalert01 have you find simple working example that have GraphQL and Mongo?
@Aneeskhan : Nope. Graffiti and GraphNoQL is not the answer that I am looking for. Have you got one?
@spyalert01 Why Graffiti is not an answer for you? As I can understand your question its the solution you are missing.
@gyzerok My apology. I should explain more. I am lost seeing the example in the Graffiti+GraphQL example. I am a very newbie to Relay, GraphQL. Perhaps you can explain more, as I am seeing how I should turn relay-starter kit to link with Mongo for testing before doing my coding.
Thanks.
Have a look at https://github.com/facebook/relay/pull/184 for a Mongo/Mongoose GraphQL example.
We have added a lot of features to graffiti-mongoose. Check it out! ;)
The above projects are great. Also, if you're starting anew, I suggest using something like DataLoader as an intermediate between your graphql definitions and your database.
If we have data stored in Mongo, are we suppose to link the database.js with Mongo to deal with retrieving data for GraphQL?
I found that schema.js somehow specify the datatype, which is redundant? since we have data in mongo with its related type.
Is there a simple example on this?
is there any prefered database engine that is perfered by graphhQL?