Skip to content

Commit

Permalink
fix: remove null from query
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremybarbet committed Feb 24, 2020
1 parent 135bf12 commit 3ca4bb0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/gatsby-source-prismic-graphql/src/components/WrapPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const queryOrSource = (obj: any) => {
return null;
};

const stripSharp = (query: any) =>
traverse(query).map(function(x) {
const stripSharp = (query: any) => {
const traversed = traverse(query).map(function(x) {
if (
typeof x === 'object' &&
x.kind === 'Name' &&
Expand All @@ -34,6 +34,14 @@ const stripSharp = (query: any) =>
}
});

// Def not the best solution but couldn't find another way to remove the null values
const clean = JSON.stringify(traversed)
.replace(/,null,/gm, ',')
.replace(/,null/gm, '');

return JSON.parse(clean);
};

interface WrapPageState {
data: any;
loading: boolean;
Expand Down

0 comments on commit 3ca4bb0

Please sign in to comment.