(nodes: readonly SelectionNode[], path: string[])
| 169 | |
| 170 | /* Recursively work down the AST to find a node with a matching path */ |
| 171 | function findNodePath(nodes: readonly SelectionNode[], path: string[]): FieldNode | undefined { |
| 172 | if (!path.length) { |
| 173 | throw new Error('Path must have a length'); |
| 174 | } |
| 175 | |
| 176 | const currentPath = path[0]; |
| 177 | const found = nodes.find((node) => isFieldNode(node) && node.name.value === currentPath); |
| 178 | |
| 179 | if (found && isFieldNode(found)) { |
| 180 | const newPath = path.slice(1); |
| 181 | |
| 182 | if (!newPath.length) return found; |
| 183 | |
| 184 | if (!found.selectionSet) return; |
| 185 | return findNodePath(found.selectionSet.selections, newPath); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | export const GetMetadataPlugin = makeExtendSchemaPlugin((build: Build, options) => { |
| 190 | const [schemaName] = options.pgSchemas; |
no test coverage detected