Skip to content

Commit

Permalink
Revert "Enable filtering on linked nodes" (#3613)
Browse files Browse the repository at this point in the history
* Revert "Fix images disappearing from rendered markdown files (#3612)"

This reverts commit 01022ab.

* Revert "Bundle Netlify CMS styles (#3611)"

This reverts commit d19ec31.

* Revert "Publish"

This reverts commit 53f66a4.

* Revert "Update comment"

This reverts commit 2b22c2c.

* Revert "Enable filtering on linked nodes (#3600)"

This reverts commit 7120e5a.
  • Loading branch information
KyleAMathews committed Jan 19, 2018
1 parent 01022ab commit 751d3cf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -482,33 +482,4 @@ describe(`GraphQL Input args`, () => {

expect(result).toMatchSnapshot()
})

it(`filters on linked fields`, async () => {
const { store, getNodes } = require(`../../redux`)
const linkedNodeType = new GraphQLObjectType({
name: `Bar`,
fields: {
id: { type: GraphQLString },
},
})
let types = [{ name: `Bar`, nodeObjectType: linkedNodeType }]

store.dispatch({
type: `CREATE_NODE`,
payload: { id: `baz`, internal: { type: `Bar` } },
})

let result = await queryResult(
[...getNodes(), { linked___NODE: `baz`, foo: `bar` }],
`
{
allNode(filter: { linked: { id: { eq: "baz" } } }) {
edges { node { linked { id } } }
}
}
`,
{ types }
)
expect(result.data.allNode.edges[0].node.linked.id).toEqual(`baz`)
})
})
9 changes: 2 additions & 7 deletions packages/gatsby/src/schema/infer-graphql-input-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const {
isEmptyObjectOrArray,
} = require(`./data-tree-utils`)

const { findLinkedNode } = require(`./infer-graphql-type`)

import type {
GraphQLInputFieldConfig,
GraphQLInputFieldConfigMap,
Expand Down Expand Up @@ -203,11 +201,8 @@ export function inferInputObjectStructureFromNodes({
// setting traversing up not try to automatically infer them.
if (isRoot && EXCLUDE_KEYS[key]) return

// Infer input arguments for linked nodes
if (_.includes(key, `___NODE`)) {
value = findLinkedNode(value)
;[key] = key.split(`___`)
}
// Input arguments on linked fields aren't currently supported
if (_.includes(key, `___NODE`)) return

let field = inferGraphQLInputFields({
nodes,
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/schema/infer-graphql-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ function inferFromMapping(
}
}

export function findLinkedNode(value, linkedField, path) {
function findLinkedNode(value, linkedField, path) {
let linkedNode
// If the field doesn't link to the id, use that for searching.
if (linkedField) {
Expand Down

0 comments on commit 751d3cf

Please sign in to comment.