I i don’t find howto or documents for meteor with graphql so i create example wit create --apollo.
I try to return query from 2 source 1 is postegres and 2 is mongo
postgres have this tabke fondi
|id|nome|descrizione|link_id|
1 | Gigi | Gigi | Sw2WTj8chR2ycYgXn |
---|---|---|---|
2 | giorgio | giorgio | 7eaSWAWqA5WmTDpJb |
and mongo have this document
{
“_id”: “Sw2WTj8chR2ycYgXn”,
“title”: “Do the Tutorial”,
“url”: “Meteor”,
“createdAt”: {
“$date”: “2021-04-17T12:27:49.373Z”
}
}
i write this schema:
`type Link {
_id: ID!
title: String
url: String
}
type Fondi {
id: ID!
nome: String
descrizione: String
link_id: String
link: Link
}
type Query {
link (link_id: ID!): Link
link_id (link_id: ID!): Link
links: [Link]
fondi: [Fondi]
}
`
and this is my resolver
const resolvers = {
Query: {
link: (Object,{link_id}) => {
debugger
return LinksCollection.findOne({_id:link_id})},
link_id: (Object,{link_id}) => {
debugger
return LinksCollection.findOne({_id:link_id})},
links: () => LinksCollection.find().fetch(),
fondi: () =>{
return knex.select("*").from("fondi")
}
}
};
but when a try to execute this query:
query {
fondi {
nome
descrizione
link_id
link {
_id
title
url
}
}
}
the link is null, this is my result:
{
"data": {
"fondi": [
{
"nome": "Gigi",
"descrizione": "Gigi",
"link_id": "Sw2WTj8chR2ycYgXn",
"link": null
},
{
"nome": "giorgio",
"descrizione": "giorgio",
"link_id": "7eaSWAWqA5WmTDpJb",
"link": null
}
]
}
}
i think link is attrubute of fondi and is a function so execute resolver function but nothing
Have any suggestion or webpages i can read?
Thank you in advance