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
fix: plugins can now query the API without content-security-policy re… #8665
Conversation
Here is the report for 4af780a (LeOndaz:main) No differences were found.
# saleor.graphql.accountbenchmark account
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
addresses for federation query count 9 9 2
customers query 48 48 0
delete staff members 34 34 0
query staff user 18 18 3
staff create 23 23 3
staff update groups and permissions 33 33 5
users for federation query count 8 8 3
# saleor.graphql.accountbenchmark permission group
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
groups for federation query count 5 5 2
permission group create 19 19 2
permission group delete 20 20 3
permission group query 7 7 0
permission group update 33 33 1
permission group update remove users with manage staff 27 27 3
# saleor.graphql.appbenchmarks app extensions
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
app extensions 14 14 0
app extensions with filter[filter0] 13 13 0
app extensions with filter[filter1] 13 13 0
app extensions with filter[filter2] 9 9 0
app extensions with filter[filter3] 11 11 0
app extensions with filter[filter4] 11 11 0
app extensions with filter[filter5] 5 5 0
app extensions with filter[filter6] 9 9 0
# saleor.graphql.appbenchmarks apps
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
apps for federation query count 9 9 3
# saleor.graphql.attributebenchmark attribute
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
attribute translation 6 6 0
attribute value translation 26 26 0
query attribute 6 6 0
query attributes 8 8 0
# saleor.graphql.checkoutbenchmark checkout mutations
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
add billing address to checkout 51 51 5
add checkout lines 52 52 4
add checkout lines with reservations 122 122 38
add delivery to checkout 60 60 7
add shipping to checkout 65 65 8
checkout email update 24 24 0
checkout payment charge 46 46 17
checkout shipping address update 70 70 11
checkout voucher code 75 75 13
complete checkout 122 122 11
complete checkout preorder 132 132 12
complete checkout with out of stock webhook 124 124 11
complete checkout with single line 124 124 11
create checkout 72 72 10
create checkout for cc 63 63 8
create checkout with reservations 117 117 21
customer complete checkout 165 165 37
customer complete checkout for cc 164 164 38
update checkout lines 53 53 4
update checkout lines with reservations 128 128 52
# saleor.graphql.checkoutbenchmark homepage
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
user checkout details 41 41 2
# saleor.graphql.discountbenchmark sales
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
sales query with channel slug 19 19 0
sales query withot channel slug 18 18 0
# saleor.graphql.discountbenchmark vouchers
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
vouchers query with channel slug 19 19 0
vouchers query withot channel slug 18 18 0
# saleor.graphql.giftcardbenchmark gift card mutations
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
create never expiry gift card 20 20 4
gift card bulk activate by staff 13 13 3
update gift card 16 16 3
# saleor.graphql.giftcardbenchmark gift card queries
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
filter gift cards by products 12 12 3
filter gift cards by tag 10 10 3
filter gift cards by used by user 11 11 3
query gift card details 11 11 3
query gift cards 10 10 3
# saleor.graphql.orderbenchmark fulfillment refund and return products
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
fulfillment refund products order lines 56 56 2
fulfillment return products order lines 109 109 14
# saleor.graphql.orderbenchmark order
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
staff multiple draft orders 400 400 306
staff multiple orders 150 150 74
staff order details 44 44 5
user order details 42 42 6
# saleor.graphql.orderbenchmark order fulfill
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
order fulfill 17 17 3
order fulfill with gift cards 17 17 3
# saleor.graphql.pagebenchmark page type
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
page types for federation query count 3 3 0
query page type 19 19 7
query page types 25 25 12
# saleor.graphql.productbenchmark category
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
categories children 3 3 0
categories for federation query count 3 3 0
category delete 109 109 27
category view 26 26 1
# saleor.graphql.productbenchmark collection
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
collection add products 44 44 10
collection bulk delete 51 51 10
collection view 6 6 0
collections for federation query count 7 7 2
create collection 47 47 12
delete collection 46 46 11
remove products from collection 41 41 10
retrieve collection channel listings 5 5 0
# saleor.graphql.productbenchmark homepage
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
report product sales 10 10 3
retrieve product list 4 4 0
# saleor.graphql.productbenchmark product
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
filter products by attributes 9 9 0
filter products by boolean attributes 19 19 0
filter products by gift card 11 11 1
filter products by numeric attributes 18 18 0
product create 70 70 3
product details 32 32 0
product translations 5 5 0
products for federation query count 6 6 2
products media for federation query count 3 3 0
products types for federation query count 2 2 0
retrieve channel listings 17 17 0
retrieve product attributes 9 9 0
retrieve product images 4 4 0
retrieve product media 4 4 0
retrive products with product types and attributes 7 7 0
update product 46 46 4
# saleor.graphql.productbenchmark product variant channel listing update
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
variant channel listing update 50 50 5
# saleor.graphql.productbenchmark variant
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
product variant bulk create 59 59 2
product variant create 75 75 6
products variants for federation query count 6 6 2
retrieve variant list 28 28 2
update product variant 79 79 12
# saleor.graphql.productbenchmark variant stocks
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
product variants stocks create 27 27 5
product variants stocks create with single webhook called 25 25 5
product variants stocks delete 27 27 5
product variants stocks delete with out of stock webhook many calls 23 23 3
product variants stocks update 29 29 5
query product variants stocks 10 10 0
# saleor.graphql.producttest product sorting attributes
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
sort product not having attribute data 23 23 0
# saleor.graphql.shippingbenchmark shipping methods
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
vouchers query with channel slug 10 10 0
vouchers query without channel slug 9 9 0
# saleor.graphql.shopbenchmark homepage
test name left count right count duplicate count
------------------------------------------------------------------------ ----------- ----------- ---------------
retrieve shop 6 6 0
|
Codecov Report
@@ Coverage Diff @@
## main #8665 +/- ##
==========================================
- Coverage 93.02% 93.01% -0.01%
==========================================
Files 499 500 +1
Lines 38265 38371 +106
Branches 4422 6527 +2105
==========================================
+ Hits 35596 35692 +96
- Misses 1782 1791 +9
- Partials 887 888 +1
Continue to review full report at Codecov.
|
Kindly note that I wanted to access the plugin configuration in the schema of the GraphQLView above, and the only 2 way I could use are, either extend the GraphQLView and let it accept new parameters, or monkey-patch it on the request on the fly
And this lets me think of, why don't we return the
|
@korycins @patrys @maarcingebala Not sure I know someone else here, can we discuss this? |
@LeOndaz, could you start by describing the use case/problem you're trying to solve? I'm not sure I understand why that change is beneficial. |
Hello @patrys , it's nice to hear from you again, let me elaborate Plugins extend the core functionality, but webhook are restful, we can make the plugins expose a GraphQL endpoint as well, but we do need the plugin to use the same playground instead of copying it around just to edit the content security policy, plugins at the moment can't use playground.html because content security policy doesn't allow urls other than |
@LeOndaz, I get it. That makes sense. |
@patrys So basically, we can't render the template from any urls other than {{ api_uri }}, but plugins need to render it because some plugins may want to add a GraphQL playground on their own then we federate all of them at the end, this is the first step towards allowing plugins to be GraphQL services, another step was suggested above and here's a demo: The
and the implementation is
|
@patrys can you also give me your opinion about the |
…stricting playground.html
@patrys not sure why it is failing, I'll appreciate some help and how can this be merged |
{"api_url": request.build_absolute_uri(str(API_PATH))}, | ||
{ | ||
"api_url": request.build_absolute_uri(str(API_PATH)), | ||
"plugins_url": request.build_absolute_uri("/plugins/"), |
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.
Looks good but shouldn't we have this URL defined in urls.py
and use the reverse
function here? I'm not sure as there is no view /plugins/
; there is the plugins/(?P<plugin_id>[.0-9A-Za-z_\-]+)/
named URL but it requires the ID.
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.
reverse won't work because it's not defined in url.py, but build_absolute_uri works because it just takes a path and returns it relative to the current host
P.S: This is tested
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.
👍
@maarcingebala look closely at my example above, the schema is rendered correctly but it has no access to the plugin configuration |
This is something tricky, plugins can now query the /graphql/ API. This update introduces the following pattern:
And plugins can have their endpoints on /plugins/plugin_id/
Then we can federate the plugins with the base GraphQL API.