This repository has been archived by the owner on Nov 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from henrikwirth/feature/code-exporter
Adds Code-Exporter to WPGraphiQL
- Loading branch information
Showing
15 changed files
with
143 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<head><link href="/static/css/main.e7f7b683.css" rel="stylesheet"></head><script type="text/javascript" src="/static/js/main.082a1d43.js"></script> | ||
<head><link href="/static/css/main.aafb6422.css" rel="stylesheet"></head><script type="text/javascript" src="/static/js/main.fe7dc498.js"></script> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...ts/app/build/static/css/main.e7f7b683.css → ...ts/app/build/static/css/main.aafb6422.css
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const getQuery = (arg, spaceCount) => { | ||
const { operationDataList } = arg | ||
const { query } = operationDataList[0] | ||
const anonymousQuery = query.replace(/query\s.+{/gim, `{`) | ||
return ( | ||
` `.repeat(spaceCount) + | ||
anonymousQuery.replace(/\n/g, `\n` + ` `.repeat(spaceCount)) | ||
) | ||
} | ||
|
||
const pageQuery = { | ||
name: `Page query`, | ||
language: `Gatsby`, | ||
codeMirrorMode: `jsx`, | ||
options: [], | ||
generate: arg => `import React from "react" | ||
import { graphql } from "gatsby" | ||
const ComponentName = ({ data }) => <pre>{JSON.stringify(data, null, 4)}</pre> | ||
export const query = graphql\` | ||
${getQuery(arg, 2)} | ||
\` | ||
export default ComponentName | ||
`, | ||
} | ||
|
||
const staticHook = { | ||
name: `StaticQuery hook`, | ||
language: `Gatsby`, | ||
codeMirrorMode: `jsx`, | ||
options: [], | ||
generate: arg => `import React from "react" | ||
import { useStaticQuery, graphql } from "gatsby" | ||
const ComponentName = () => { | ||
const data = useStaticQuery(graphql\` | ||
${getQuery(arg, 4)} | ||
\`) | ||
return <pre>{JSON.stringify(data, null, 4)}</pre> | ||
} | ||
export default ComponentName | ||
`, | ||
} | ||
|
||
const staticQuery = { | ||
name: `StaticQuery`, | ||
language: `Gatsby`, | ||
codeMirrorMode: `jsx`, | ||
options: [], | ||
generate: arg => `import React from "react" | ||
import { StaticQuery, graphql } from "gatsby" | ||
const ComponentName = () => ( | ||
<StaticQuery | ||
query={graphql\` | ||
${getQuery(arg, 6)} | ||
\`} | ||
render={data => <pre>{JSON.stringify(data, null, 4)}</pre>} | ||
></StaticQuery> | ||
) | ||
export default ComponentName | ||
`, | ||
} | ||
|
||
export default [pageQuery, staticHook, staticQuery] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters