Skip to content

Commit

Permalink
feat: Make the constant value a JSON scalar
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jun 28, 2020
1 parent 5a537f0 commit b053c00
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
9 changes: 8 additions & 1 deletion plugins/gatsby-source-newrelic-sdk/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ exports.createSchemaCustomization = ({ actions, schema }) => {

const typeDefs = `
type NewRelicSdkComponent implements Node {
constants: [NewRelicSdkConstant!]!
propTypes: [NewRelicSdkPropTypeDefinition!]!
typeDefs: [NewRelicSdkTypeDefinition]
typeDefs: [NewRelicSdkTypeDefinition!]!
}
type NewRelicSdkApi implements Node {
constants: [NewRelicSdkConstant!]!
typeDefs: [NewRelicSdkTypeDefinition]
}
Expand Down Expand Up @@ -107,6 +109,11 @@ exports.createSchemaCustomization = ({ actions, schema }) => {
description: String
type: String!
}
type NewRelicSdkConstant {
name: String!
value: JSON!
}
`;

createTypes([propTypeMeta, typeDefs]);
Expand Down
7 changes: 1 addition & 6 deletions plugins/gatsby-source-newrelic-sdk/src/constantInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ exports.getConstants = (name, sdk) => {

return {
name: `${name}.${member}`,
type: Array.isArray(value) ? 'array' : typeof value,
values: Array.isArray(value)
? value.map((el) => JSON.stringify(el))
: Object.getOwnPropertyNames(value).map(
(key) => `${key}: ${JSON.stringify(value[key])}`
),
value: JSON.stringify(value),
};
});
};
2 changes: 2 additions & 0 deletions plugins/gatsby-source-newrelic-sdk/src/navigationApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module.exports = {
name: 'navigation',
description: '',
usage: "import { navigation } from 'nr1'",
constants: [],
examples: [],
typeDefs: [
{
name: 'Nerdlet',
Expand Down

0 comments on commit b053c00

Please sign in to comment.