Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
graphql_twig
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
graphql_twig
Commits
392d38d8
Commit
392d38d8
authored
1 year ago
by
Tuukka Hakala
Committed by
Eli
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Resolve
#3392635
"Debug button not shown"
parent
c5143df8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!6
Resolve #3392635 "Debug button not shown"
Pipeline
#34123
canceled
1 year ago
Stage: build
Stage: validate
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
assets/debug.js
+32
-21
32 additions, 21 deletions
assets/debug.js
graphql_twig.libraries.yml
+0
-1
0 additions, 1 deletion
graphql_twig.libraries.yml
src/GraphQLTemplateTrait.php
+6
-4
6 additions, 4 deletions
src/GraphQLTemplateTrait.php
with
38 additions
and
26 deletions
assets/debug.js
+
32
−
21
View file @
392d38d8
((
$
,
Drupal
)
=>
{
((
Drupal
,
once
)
=>
{
'
use strict
'
;
Drupal
.
behaviors
.
graphqlTwigDebug
=
{
attach
:
(
context
)
=>
{
$
(
once
(
'
graphql-debug
'
,
'
.graphql-twig-debug-wrapper
'
,
context
)).
each
(
()
=>
{
const
query
=
$
(
this
).
attr
(
'
data-graphql-query
'
);
once
(
'
graphql-debug
'
,
'
.graphql-twig-debug-wrapper
'
,
context
).
forEach
((
element
)
=>
{
const
query
=
element
.
dataset
.
graphqlQuery
;
const
server
=
element
.
dataset
.
graphqlServer
;
let
variables
=
element
.
dataset
.
graphqlVariables
;
const
form
=
document
.
createElement
(
'
form
'
);
form
.
action
=
Drupal
.
url
(
`admin/config/graphql/servers/manage/
${
server
}
/explorer`
);
form
.
method
=
'
post
'
;
form
.
target
=
'
_blank
'
;
const
txt
=
document
.
createElement
(
'
textarea
'
);
txt
.
innerHTML
=
variables
;
variables
=
txt
.
value
;
let
variables
=
$
(
this
).
attr
(
'
data-graphql-variables
'
);
const
queryInput
=
document
.
createElement
(
'
input
'
);
queryInput
.
type
=
'
hidden
'
;
queryInput
.
name
=
'
query
'
;
queryInput
.
value
=
query
;
const
$form
=
$
(
'
<form method="post" target="_blank"></form>
'
)
.
attr
(
'
action
'
,
Drupal
.
url
(
'
graphql/explorer
'
))
.
appendTo
(
this
);
const
variablesInput
=
document
.
createElement
(
'
input
'
);
variablesInput
.
type
=
'
hidden
'
;
variablesInput
.
name
=
'
variables
'
;
variablesInput
.
value
=
variables
;
const
txt
=
document
.
createElement
(
'
textarea
'
);
const
button
=
document
.
createElement
(
'
input
'
);
button
.
type
=
'
submit
'
;
button
.
classList
.
add
(
'
graphql-twig-debug-button
'
);
button
.
value
=
'
Inspect GraphQL query
'
;
txt
.
innerHTML
=
variables
;
variables
=
txt
.
value
;
$
(
'
<input type="hidden" name="query"/>
'
).
val
(
query
).
appendTo
(
$form
);
$
(
'
<input type="hidden" name="variables"/>
'
)
.
val
(
variables
)
.
appendTo
(
$form
);
$
(
'
<input type="submit" class="graphql-twig-debug-button" value="Inspect GraphQL query"/>
'
,
).
appendTo
(
$form
);
},
);
form
.
append
(
queryInput
,
variablesInput
,
button
);
element
.
append
(
form
);
});
},
};
})(
jQuery
,
Drupal
);
})(
Drupal
,
once
);
This diff is collapsed.
Click to expand it.
graphql_twig.libraries.yml
+
0
−
1
View file @
392d38d8
...
...
@@ -6,6 +6,5 @@ debug:
js
:
assets/debug.js
:
{}
dependencies
:
-
core/jquery
-
core/once
-
core/drupal
This diff is collapsed.
Click to expand it.
src/GraphQLTemplateTrait.php
+
6
−
4
View file @
392d38d8
...
...
@@ -97,10 +97,11 @@ trait GraphQLTemplateTrait {
if
(
$this
->
env
->
isDebug
()
&&
$debug_placement
==
'wrapped'
)
{
printf
(
'<div class="%s" data-graphql-query="%s" data-graphql-variables="%s">'
,
'<div class="%s" data-graphql-query="%s" data-graphql-variables="%s"
data-graphql-server="%s"
>'
,
'graphql-twig-debug-wrapper'
,
htmlspecialchars
(
$query
),
htmlspecialchars
(
json_encode
(
$arguments
))
htmlspecialchars
(
json_encode
(
$arguments
)),
$this
->
env
->
getGraphQlServer
()
?->
id
()
);
}
...
...
@@ -123,10 +124,11 @@ trait GraphQLTemplateTrait {
if
(
$this
->
env
->
isDebug
()
&&
$debug_placement
==
'inside'
)
{
$context
[
'graphql_debug'
]
=
[
'#markup'
=>
sprintf
(
'<div class="graphql-twig-debug-child"><div class="%s" data-graphql-query="%s" data-graphql-variables="%s"></div></div>'
,
'<div class="graphql-twig-debug-child"><div class="%s" data-graphql-query="%s" data-graphql-variables="%s"
data-graphql-server="%s"
></div></div>'
,
'graphql-twig-debug-wrapper'
,
htmlspecialchars
(
$query
),
htmlspecialchars
(
json_encode
(
$arguments
))
htmlspecialchars
(
json_encode
(
$arguments
)),
$this
->
env
->
getGraphQlServer
()
?->
id
()
),
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment