A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.gatsbyjs.com/docs/reference/graphql-data-layer/node-model/ below:

Website Navigation


Node Model | Gatsby

Gatsby exposes its internal data store and query capabilities to GraphQL field resolvers on context.nodeModel.

Example Usage

Start building today on

Netlify!

Methods

Get all nodes in the store, or all nodes of a specified type (optionally with limit/skip). Returns slice of result as iterable and total count of nodes.

You can directly return its entries result in your resolver.

Parameters Return value

Promise<Object>

Object containing { entries: GatsbyIterable, totalCount: () => Promise<number> }

Example

const { entries, totalCount } = await findAll({ type: `MyType` })


const { entries, totalCount } = await findAll({
  type: `MyType`,
  query: {
    sort: { date: `desc` },
    filter: { published: { eq: false } },
  },
})


const { entries, totalCount } = await findAll({ type: `MyType` })

const count = await totalCount()
const filteredEntries = entries.filter(entry => entry.published)


const filteredEntries = entries.filter(entry => entry.published)
return Array.from(posts).length

Get one node in the store. Only returns the first result. When possible, always use this method instead of fetching all nodes and then filtering them. findOne is more performant in that regard.

Parameters Example

const node = await findOne({
  type: `MyType`,
  query: { filter: { title: { eq: `My Title` } } },
})

Finds top most ancestor of node that contains passed Object or Array

Parameters Return value

Node

Top most ancestor if predicate is not specified or first node that meet predicate conditions if predicate is specified

Utility to get a field value from a node, even when that value needs to be materialized first (e.g. nested field that was connected via @link directive)

Parameters Example

const blogPostNode = {
  author: 'author-id-1',
  
}

getFieldValue(blogPostNode, 'author.name')

Get a node from the store by ID and optional type.

Parameters Example

getNodeById({ id: `123` })

getNodeById({ id: `123`, type: `MyType` })

getNodeById({ id: `123` }, { path: `/` })

Get nodes from the store by IDs and optional type.

Parameters Example

getNodesByIds({ ids: [`123`, `456`] })


getNodesByIds({ ids: [`123`, `456`], type: `MyType` })


getNodesByIds({ ids: [`123`, `456`] }, { path: `/` })

Get the names of all node types in the store.

Replace the cache either with the value passed on (mainly for tests) or an empty new Map.

Parameters

Adds link between inline objects/arrays contained in Node object and that Node object.

Parameters

Given a result, that’s either a single node or an array of them, track them using pageDependencies. Defaults to tracking according to current resolver path. Returns the result back.

Parameters

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4