How to use the gatsby.StaticQuery.propTypes function in gatsby

To help you get started, we’ve selected a few gatsby examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github birkir / gatsby-source-graphql-universal / src / index.js View on Github external
import React from 'react';
import gql from 'graphql-tag';
import ApolloClient from 'apollo-boost';
import traverse from 'traverse';
import cloneDeep from 'lodash.clonedeep';
import { StaticQuery } from 'gatsby';
import PropTypes from 'prop-types';

// Allow string OR patched queries format (in development)
if (StaticQuery && typeof StaticQuery === 'object' && StaticQuery.propTypes) {
  StaticQuery.propTypes.query = PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.shape({
      id: PropTypes.string.isRequired,
      source: PropTypes.string.isRequired,
    })
  ]).isRequired;
}

const options = new Map();

export const getOptions = (name) => {
  if (!options.has(name)) {
    if (typeof window !== 'undefined') {
      setOptions(name, window.___graphqlUniversal[name])
    }
github birkir / gatsby-source-graphql-universal / src / index.js View on Github external
import React from 'react';
import gql from 'graphql-tag';
import ApolloClient from 'apollo-boost';
import traverse from 'traverse';
import cloneDeep from 'lodash.clonedeep';
import { StaticQuery } from 'gatsby';
import PropTypes from 'prop-types';

// Allow string OR patched queries format (in development)
if (StaticQuery && typeof StaticQuery === 'object' && StaticQuery.propTypes) {
  StaticQuery.propTypes.query = PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.shape({
      id: PropTypes.string.isRequired,
      source: PropTypes.string.isRequired,
    })
  ]).isRequired;
}

const options = new Map();

export const getOptions = (name) => {
  if (!options.has(name)) {
    if (typeof window !== 'undefined') {
      setOptions(name, window.___graphqlUniversal[name])
    }
  }