Get publicURL from Gatsby source based on Postgres returned id

Viewed 28

I'm running Gatsby with source-filesystem in order to generate publicURL and source-pg to connect to postgresql database.

The following query gets ids of my files:

  postgres {
    allInterestingList {
      id
  }

In my filesystem, all images have the same id as of those in allInterestingList returns.

Therefore the following query:

  allFile(filter: {name: {eq: "idFromTheInterestingList"}}) {
    edges {
      node {
        publicURL
      }
    }
  }

I would like to return and even better to merge these two, it is possible, like?

  postgres {
    allInterestingList {
      id ->   allFile(filter: {name: {eq: $id}}) {
                edges {
                  node {
                   <- publicURL
                  }
                }
              }
  }

The output should be something along these lines:

{
  "data": {
    "postgres": {
      "allInterestingList": [
         id: "123",
         publicURL: "static/img.ext"
      ]
    }
}

0 Answers
Related