Skip to content

Commit

Permalink
feat: add new relic SDK info to graphql schema
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Sep 3, 2020
1 parent 56067d5 commit 9dbcf9f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
35 changes: 33 additions & 2 deletions plugins/gatsby-source-newrelic-sdk/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -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) =>
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions plugins/gatsby-source-newrelic-sdk/src/constants.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down

0 comments on commit 9dbcf9f

Please sign in to comment.