graphile / graphile/gatsby-source-pg
Get nodes created by plugin by their type
- Dominant language
- JavaScript
- Stars
- 35
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Description
If I explore data, created by plugin, I can find:
```
postgres (PostGraphile) {
allElements (PostGraphile_ElementsConnection) {
nodes (PostGraphile_Element) {
....
}
}
}
```
And I even can modify these nodes like this:
```
exports.createResolvers = ({ createResolvers }) => {
createResolvers({
PostGraphile_Element: {
internal: {
type: `Internal`,
resolve: object => {
return {
type: `pgData`,
}
}
}
},
});
}
```
But if I try to use this node in other places with constructions:
```
if (node.internal.type === `pgData`) {
// do smth..
}
```
```
const nodes = getNodesByType(`pgData`)) || getNodesByType(`PostGraphile_Element`))
```
I get nothing.
So, If I want to build lunr index from nodes with [lunr-plugin](https://github.com/gatsby-contrib/gatsby-plugin-elasticlunr-search) I try to use such syntax, as described in its rtfm for gatsby-config.js:
```
{
resolve: `@gatsby-contrib/gatsby-plugin-elasticlunr-search`,
options: {
fields: [`name`],
// How to resolve each field`s value for a supported node type
resolvers: {
PostGraphile_Element: {
name: node => node.name,
},
// Or try to use my crated internal.type:
pgData: {
name: node => node.name,
},
},
},
},
```
The question is for I can get created child nodes by their type `PostGraphile_Element` or `pgData`
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the node examples in this issue and the gatsby-config.js configuration for gatsby-plugin-elasticlunr-search. Reproduce the getNodesByType calls for PostGraphile_Element and pgData, then determine whether the created nodes are exposed under either type; done means the expected nodes can be retrieved and used by the lunr resolver.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, postgresql
- Domain
- data, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100