From 9dbcf9f4003bd0f57838f8911e165dcfcc408f06 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Thu, 3 Sep 2020 01:56:16 -0700 Subject: [PATCH] feat: add new relic SDK info to graphql schema --- .../gatsby-source-newrelic-sdk/gatsby-node.js | 35 +++++++++++++++++-- .../src/constants.js | 3 ++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/plugins/gatsby-source-newrelic-sdk/gatsby-node.js b/plugins/gatsby-source-newrelic-sdk/gatsby-node.js index 5ac9aad74..d61085906 100644 --- a/plugins/gatsby-source-newrelic-sdk/gatsby-node.js +++ b/plugins/gatsby-source-newrelic-sdk/gatsby-node.js @@ -1,6 +1,10 @@ const loadSdk = require('./src/loadSdk'); const { getComponentDoc, getApiDoc } = require('./src/docInfo'); -const { DOCUMENTED_APIS, DOCUMENTED_COMPONENTS } = require('./src/constants'); +const { + BASE_URL, + DOCUMENTED_APIS, + DOCUMENTED_COMPONENTS, +} = require('./src/constants'); const navigationApi = require('./src/navigationApi'); const hasOwnProperty = (obj, name) => @@ -140,13 +144,40 @@ exports.createSchemaCustomization = ({ actions, schema }) => { live: Boolean! preview: Boolean! } + + type Query { + newRelicSdk: NewRelicSdk! + } + + type NewRelicSdk { + version: String! + assets: NewRelicSdkAssets! + } + + type NewRelicSdkAssets { + js: String! + css: String! + } `; createTypes([propTypeMeta, typeDefs]); }; -exports.createResolvers = ({ createResolvers }) => { +exports.createResolvers = ({ createResolvers }, pluginOptions) => { + const { release } = pluginOptions; + createResolvers({ + Query: { + newRelicSdk: { + resolve: () => ({ + version: release, + assets: { + js: `${BASE_URL}-${release}.js`, + css: `${BASE_URL}-${release}.css`, + }, + }), + }, + }, NewRelicSdkFunctionReturnValue: { type: { resolve: (source) => source.promiseType || source.type, diff --git a/plugins/gatsby-source-newrelic-sdk/src/constants.js b/plugins/gatsby-source-newrelic-sdk/src/constants.js index 997850e58..79bc51813 100644 --- a/plugins/gatsby-source-newrelic-sdk/src/constants.js +++ b/plugins/gatsby-source-newrelic-sdk/src/constants.js @@ -1,3 +1,6 @@ +module.exports.BASE_URL = + '//hypertext-sandbox.nr-assets.net/wanda--wanda-ec-ui--nr1-docs'; + module.exports.DOCUMENTED_APIS = ['logger', 'navigation', 'nerdlet']; module.exports.DOCUMENTED_COMPONENTS = [ 'AccountPicker',