-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(CodeBlock): Pass variables into graphqlPlayground url #362
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,26 +8,29 @@ import { SIZE_TO_SMALLER, Size } from '../../private/size'; | |
const URL = url.URL ?? window.URL; | ||
|
||
interface Props { | ||
children: string; | ||
query: string; | ||
variables: string | undefined; | ||
graphqlPlayground: string; | ||
size: Size; | ||
} | ||
|
||
export const GraphQLPlaygroundAction = ({ | ||
children, | ||
query, | ||
variables, | ||
graphqlPlayground, | ||
size, | ||
}: Props) => { | ||
const playgroundUrl = new URL(graphqlPlayground); | ||
playgroundUrl.searchParams.set('query', children); | ||
playgroundUrl.searchParams.set('query', query); | ||
playgroundUrl.searchParams.set('variables', variables ?? '{}'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this work for JSONC variables? They're used in e.g. position posting: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't run though:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, yeah. We probably want to strip out comments? Doesn't look like GraphiQL supports it - graphql/graphiql#780 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we should be able to use |
||
const href = playgroundUrl.toString(); | ||
|
||
const smallerSize = SIZE_TO_SMALLER[size]; | ||
|
||
return ( | ||
<Text size={smallerSize} weight="medium"> | ||
<TextLink href={href} rel="noreferrer" target="_blank"> | ||
<IconVideo alignY="lowercase" /> Playground | ||
<IconVideo alignY="lowercase" /> GraphQL Explorer | ||
</TextLink> | ||
</Text> | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about this to avoid parsing/stringifying empty objects for other code block types: