-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR introduces a pre-processing step scanning the gql schemas from Sanity for directives that indicate a field or type as a cross dataset reference. When these directives are found, the corresponding fields are manipulated to be treated as normal references with the expectation that the user will add another source config for the target dataset in the Gatsby app configuration. Through Gatsby schema composition the types should then match up, and the node resolution should also pick out the target documents. The main implementation to review is found in `packages/gatsby-source-sanity/src/util/mapCrossDatasetReferences.ts` End to end tests de-referencing both normal and cross dataset references from actual Sanity datasets are included in the `cdrs` Gatsby app in `examples`. To run tests, first make sure the test app is running ```bash cd examples/cdrs && rm -rf .cache public && npm run develop ``` Then run the test suite in that folder ```bash cd examples/cdrs && npm test ``` --------- Co-authored-by: Binoy Patel <[email protected]>
- Loading branch information
Showing
27 changed files
with
52,746 additions
and
10,315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# dotenv environment variable files | ||
.env* | ||
|
||
# gatsby files | ||
.cache/ | ||
public | ||
|
||
# Mac files | ||
.DS_Store | ||
|
||
# Yarn | ||
yarn-error.log | ||
.pnp/ | ||
.pnp.js | ||
# Yarn Integrity file | ||
.yarn-integrity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.cache | ||
package.json | ||
package-lock.json | ||
public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"arrowParens": "avoid", | ||
"semi": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
This is a test Gatsby app for end-to-end testing the gatsby-source-sanity plugin with Sanity Content Lake data and schema | ||
|
||
# Testing | ||
Manually run the application | ||
|
||
```bash | ||
rm -rf .cache public && npm run develop | ||
``` | ||
|
||
Run the test suite | ||
|
||
```bash | ||
npm test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Configure your Gatsby site with this file. | ||
* | ||
* See: https://www.gatsbyjs.com/docs/reference/config-files/gatsby-config/ | ||
*/ | ||
|
||
const path = require("path") | ||
const pluginPath = path.resolve( | ||
__dirname, | ||
"../../packages/gatsby-source-sanity" | ||
) | ||
|
||
/** | ||
* @type {import('gatsby').GatsbyConfig} | ||
*/ | ||
module.exports = { | ||
siteMetadata: { | ||
title: `Gatsby Default Starter`, | ||
description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`, | ||
author: `@gatsbyjs`, | ||
siteUrl: `https://gatsbystarterdefaultsource.gatsbyjs.io/`, | ||
}, | ||
plugins: [ | ||
{ | ||
resolve: pluginPath, | ||
options: { | ||
apiHost: "https://api.sanity.work", | ||
projectId: "rz9j51w2", | ||
dataset: "production", | ||
}, | ||
}, | ||
{ | ||
resolve: pluginPath, | ||
options: { | ||
apiHost: "https://api.sanity.work", | ||
projectId: "rz9j51w2", | ||
dataset: "shared", | ||
}, | ||
}, | ||
`gatsby-plugin-image`, | ||
], | ||
} |
Oops, something went wrong.