rans>Skip to main content
Community Plugin
View plugin on GitHub
See starters using this

gatsby-source-nasa

This source plugin for Gatsby will make NASA NEO (Near Earth Object) URLs available in GraphQL queries.

Installation

# Install the plugin
yarn add gatsby-source-nasa-neo

In gatsby-config.js:

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-source-nasa-neo',
      options: {
        key: "YOUR_NASA_API_KEY",
        neo: [
          {
            type: 'feed',
            start_date: ,
            end_date:
          },
          {
            type: 'lookup',
            id:
          },
          {
            type: 'browse'
          },
        ]
      },
    }
  ]
};

NOTE: To get a NASA API key, register here.

Configuration Options

The configuration options for this plugin are currently very small. You can set ‘feed’ and/or ‘lookup’ types and provide an optional start/end date in YYYY-MM-DD format.

Example Configuration

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-source-nasa-neo',
      options: {
        key: process.env.NASA_API_KEY,
        neo: [
          {
            type: 'feed',
            start_date: '2019-01-01',
            end_date: '2019-09-01'
          },
          {
            type: 'lookup',
            id: '3542519'
          },
          {
            type: 'browse'
          }
        ]
      }
    }
  ]
};

Querying NASA NEO information

Once the plugin is configured, one new query is available in GraphQL: allNasaData.

Here are example queries to load APOD and EPIC images:

query FeedQuery {
  allNasaData(filter: {type: {eq: "feed"}}) {
    edges {
      node {
        type
        date
        url
      }
    }
  }
}
query LookupQuery {
  allNasaData(filter: {type: {eq: "lookup"}}) {
    edges {
      node {
        type
        date
        url
      }
    }
  }
}
query BrowseQuery {
  allNasaData(filter: {type: {eq: "browse"}}) {
    edges {
      node {
        type
        date
        url
      }
    }
  }
}

See the GraphiQL UI for info on all returned fields.

Docs
Tutorials
Plugins
Blog
Showcase