├── .gitignore ├── example ├── cypress.json ├── cypress.prod.json ├── .prettierrc ├── src │ ├── images │ │ ├── gatsby-icon.png │ │ └── gatsby-astronaut.png │ ├── graphql │ │ └── test.fragment.js │ ├── pages │ │ ├── 404.js │ │ ├── page-2.js │ │ └── index.tsx │ └── components │ │ ├── best-film.js │ │ ├── header.js │ │ ├── image.js │ │ ├── layout.js │ │ ├── seo.js │ │ └── layout.css ├── gatsby-node.js ├── cypress │ ├── fixtures │ │ └── example.json │ ├── integration │ │ └── example.spec.js │ ├── support │ │ ├── index.js │ │ └── commands.js │ └── plugins │ │ └── index.js ├── gatsby-browser.js ├── gatsby-ssr.js ├── LICENSE ├── .gitignore ├── gatsby-config.js ├── package.json └── README.md ├── packages └── gatsby-source-graphql-universal │ ├── index.js │ ├── utils.js │ ├── gatsby-node.js │ ├── gatsby-ssr.js │ ├── getRootQuery.js │ ├── babel-loader.js │ ├── .babelrc │ ├── babel-plugin-remove-graphql-queries.js │ ├── dist │ ├── getGraphqlExpr.js │ ├── utils.js │ ├── gatsby-ssr.js │ ├── getRootQuery.js │ ├── gatsby-node.js │ ├── babel-loader.js │ ├── third-party │ │ └── gatsby-node.js │ ├── index.js │ └── babel-plugin-remove-graphql-queries.js │ ├── src │ ├── gatsby-ssr.js │ ├── utils.js │ ├── getGraphqlExpr.js │ ├── getRootQuery.js │ ├── gatsby-node.js │ ├── babel-loader.js │ ├── index.js │ └── babel-plugin-remove-graphql-queries.js │ ├── scripts │ ├── patch.sh │ └── patches │ │ ├── babel-loader.patch │ │ └── babel-plugin-remove-graphql-queries.patch │ ├── index.d.ts │ ├── package.json │ ├── jest.config.js │ └── __tests__ │ ├── babel-plugin-remove-graphql-queries.spec.js │ └── __snapshots__ │ └── babel-plugin-remove-graphql-queries.spec.js.snap ├── .travis.yml ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | /*.js 3 | .cache -------------------------------------------------------------------------------- /example/cypress.json: -------------------------------------------------------------------------------- 1 | { 2 | "baseUrl": "http://localhost:8000/", 3 | "video": false 4 | } -------------------------------------------------------------------------------- /packages/gatsby-source-graphql-universal/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./dist/index') -------------------------------------------------------------------------------- /packages/gatsby-source-graphql-universal/utils.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./dist/utils') -------------------------------------------------------------------------------- /example/cypress.prod.json: -------------------------------------------------------------------------------- 1 | { 2 | "baseUrl": "http://localhost:9000/", 3 | "video": false 4 | } -------------------------------------------------------------------------------- /packages/gatsby-source-graphql-universal/gatsby-node.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./dist/gatsby-node') -------------------------------------------------------------------------------- /packages/gatsby-source-graphql-universal/gatsby-ssr.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./dist/gatsby-ssr') -------------------------------------------------------------------------------- /packages/gatsby-source-graphql-universal/getRootQuery.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./dist/getRootQuery') -------------------------------------------------------------------------------- /example/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5" 5 | } 6 | -------------------------------------------------------------------------------- /packages/gatsby-source-graphql-universal/babel-loader.js: -------------------------------------------------------------------------------- 1 | module.exports = require(`./dist/babel-loader`); 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - node 4 | addons: 5 | apt: 6 | packages: 7 | - libgconf-2-4 -------------------------------------------------------------------------------- /packages/gatsby-source-graphql-universal/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["babel-preset-gatsby-package"] 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /example/src/images/gatsby-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prismicio/gatsby-source-graphql-universal/master/example/src/images/gatsby-icon.png -------------------------------------------------------------------------------- /packages/gatsby-source-graphql-universal/babel-plugin-remove-graphql-queries.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./dist/babel-plugin-remove-graphql-queries') -------------------------------------------------------------------------------- /example/src/images/gatsby-astronaut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prismicio/gatsby-source-graphql-universal/master/example/src/images/gatsby-astronaut.png -------------------------------------------------------------------------------- /example/gatsby-node.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's Node APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/node-apis/ 5 | */ 6 | 7 | // You can delete this file if you're not using it -------------------------------------------------------------------------------- /example/cypress/fixtures/example.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Using fixtures to represent data", 3 | "email": "hello@cypress.io", 4 | "body": "Fixtures are a great way to mock data for responses to routes" 5 | } -------------------------------------------------------------------------------- /example/src/graphql/test.fragment.js: -------------------------------------------------------------------------------- 1 | import { graphql } from 'gatsby'; 2 | 3 | // export const fragment = graphql` 4 | // fragment Planet on SWAPI_Planet { 5 | // id 6 | // name 7 | // } 8 | // ` -------------------------------------------------------------------------------- /example/gatsby-browser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's Browser APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/browser-apis/ 5 | */ 6 | 7 | // You can delete this file if you're not using it -------------------------------------------------------------------------------- /example/gatsby-ssr.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's SSR (Server Side Rendering) APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/ssr-apis/ 5 | */ 6 | 7 | // You can delete this file if you're not using it 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "private": true, 4 | "workspaces": { 5 | "packages": [ 6 | "packages/*", 7 | "example" 8 | ] 9 | }, 10 | "scripts": { 11 | "build": "yarn workspaces run build", 12 | "clean": "yarn workspaces run clean", 13 | "test": "yarn clean && yarn build && yarn workspaces run test" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/src/pages/404.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | import Layout from '../components/layout' 4 | import SEO from '../components/seo' 5 | 6 | const NotFoundPage = () => ( 7 | 8 | 9 |

NOT FOUND

10 |

You just hit a route that doesn't exist... the sadness.

11 |
12 | ) 13 | 14 | export default NotFoundPage 15 | -------------------------------------------------------------------------------- /example/cypress/integration/example.spec.js: -------------------------------------------------------------------------------- 1 | 2 | describe("smoke test", () => { 3 | beforeEach(() => { 4 | cy.visit("/") 5 | }) 6 | 7 | it("check header test", () => { 8 | cy.get("#gatsby-focus-wrapper > div:nth-child(1) > div > h1").contains("Gatsby Default Starter") 9 | }) 10 | 11 | it("check section text", () => { 12 | cy.get("#gatsby-focus-wrapper > div:nth-child(2) > h1").contains("List of movies") 13 | }) 14 | }) -------------------------------------------------------------------------------- /example/src/pages/page-2.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { Link } from 'gatsby' 3 | 4 | import Layout from '../components/layout' 5 | import SEO from '../components/seo' 6 | 7 | const SecondPage = () => ( 8 | 9 | 10 |

Hi from the second page

11 |

Welcome to page 2

12 | Go back to the homepage 13 |
14 | ) 15 | 16 | export default SecondPage 17 | -------------------------------------------------------------------------------- /packages/gatsby-source-graphql-universal/dist/getGraphqlExpr.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | module.exports = function getGraphqlExpr(t, queryHash, source) { 4 | return t.objectExpression([t.objectProperty(t.identifier('id'), t.stringLiteral(queryHash)), t.objectProperty(t.identifier('source'), t.stringLiteral(source)), t.objectMethod('method', t.identifier('toString'), [], t.blockStatement([t.returnStatement(t.memberExpression(t.identifier('this'), t.identifier('id')))]))]); 5 | }; -------------------------------------------------------------------------------- /packages/gatsby-source-graphql-universal/dist/utils.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const { 4 | prepareOptions 5 | } = require(`gatsby/dist/utils/babel-loader-helpers`); 6 | 7 | exports.prepareOptions = (babel, options = {}, resolve = require.resolve) => { 8 | const items = prepareOptions(babel, options, resolve); 9 | 10 | if (items.length > 2) { 11 | items[3].splice(0, 1, babel.createConfigItem([require.resolve('@prismicio/gatsby-source-graphql-universal/babel-plugin-remove-graphql-queries.js')], { 12 | type: 'plugin' 13 | })); 14 | } 15 | 16 | return items; 17 | }; -------------------------------------------------------------------------------- /packages/gatsby-source-graphql-universal/src/gatsby-ssr.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | exports.onRenderBody = ({ setHeadComponents }, pluginOptions) => { 4 | const { typeName, fieldName, url, headers } = pluginOptions; 5 | setHeadComponents([ 6 |