disable graphql queries other than crud in strapi v4 - api

I want to create a public facing API to fetch product, category etc. using strapi v4 graphql plugin.
I can disable some crud queries in the src/index.js file using the example here.
However I don't know how to disable the queries and mutations of things that are not part of shadowCRUD such as uploadFile, uploadFolder, i18Nlocale, usersPermissions, register, login etc.
How can I achieve this in strapi v4 (v4.3.4 as of right now)

extensionService.shadowCRUD('plugin::users-permissions.role').disableQueries();
extensionService.shadowCRUD('plugin::i18n.locale').disableQueries();
extensionService.shadowCRUD('plugin::upload.folder').disableQueries();
extensionService.shadowCRUD('plugin::upload.folder').disableMutations();
extensionService.shadowCRUD('plugin::upload.file').disableMutations();
extensionService.shadowCRUD('plugin::upload.file').disableQueries();
Adding these lines did help but still some of the non-content specific mutations are there (userPermissionsUser, userPermissionsRole). Still, I think there's a much cleaner way to do this somewhere.

Related

how to get data from backend in nuxt 3 without using composition api

I hope you are fine. I want to send a get request in nuxt3 without using composition api but I don't know how to do that. I will thank anyone who give me a piece of guidance.
Thanks.
async getPosters(){
const results = await this.$axios.get('posters')
this.posters = results.data
},
Write your code as you were used too with just Options API, nothing have changed on that matter.
You can totally use Options API while using Vue3/Nuxt3. They may have some small changes but nothing too major for a simple task of querying a backend.
It looks like this is more of an issue with trying to load Axios rather than it is with the composition API. Nuxt 3 makes Axios a redundant module.
Since Fetch is the go-to considered method of requesting data in Nuxt3, have you tried changing the method of your request? It means having to load one less module for your project, and will make it a lot easier to transition between SSR and Static in the future. If not, it might be worth using the previous version of Nuxt.
Here's the documentation: https://v3.nuxtjs.org/getting-started/data-fetching in Nuxt 3.

How to use Vuejs and CMS Strapi for multilingual functionality

I am using VueJS to interface and manage CMS + content with Strapi, Strapi has supported me to create multilingual records in a data table just when calling the api call with the correct key locales=' xxx' is fine.
However, I still don't know how to make it work. According to my logic in the dropdown to change the language when I click on EN or FR,... will check the condition to change the call api path... But the algorithm syntax I still don't know what to do like, hope to get help from you ^^ many thanks!

Shopify Interact with product page HTML via app

We plan to create a Shopify app but we face some problems to find in documentations how to interact with pages.
I`m not sure we must ask every time users to add codes and etc, so I need to know if I miss something.
I need to interact with the product pages in Shopify from an app.
I search and read all the web for this and everything is how to start but not the actual examples.
I know for the ScriptTags and how to include them but that is.
If someone can give me a simple example of how for example to hide the Buy button and insert something on instead.
I know how to select it with the default theme with JQuery but what about all other themes?
There are two ways to interact with the front page:
1) Inject some code in the page ( the live one )
2) Use ScriptTag as you mentioned.
The code injection script will modify the product template for example and inject your code if you like to do this automatically or you can instruct the user to do so on their own, but if they are not code savvy there might be issues.
In addition this code will live only on the live theme in most cases. And if the user likes to delete your app at a specific time you must be sure to write the logic in such way that it won't affect the site if your app is no longer present ( since it will be really hard to clean up the files once you add the code automatically )
For this approach you will need to use the Asset API.
You will need to get the content of the file with a GET request to the file and make a put request in order to update it.
The better approach is to use ScriptTag API.
This will allow the use of a script file that will be attached on EVERY theme. This will not modify the theme files in any form or shape.
It seems that this is the approach that you are looking for.
Please have in mind that you will be the one hosting the file from your app so pretty much you can write what ever you like there. So if you like to use jQuery you must be sure that the themes have included jQuery or you will have to add the jQuery core code inside your script.
As for how to write a script tag, there is a pretty straightforward documentation here: https://help.shopify.com/en/api/reference/online-store/scripttag#create-2020-01

load, save and reload ajax api-responses with vuex

I have a vue3-app that serves as the frontend of an asp.net core 2 api.
Much of the requested data gets used by multiple components. And in order not to make multiple identical requests, i want to store the response-data in my vuex-store if it's not in there already.
The problem is, that most of that data changes a lot, so i need to be able to tell vuex to refresh the data after some time.
But i don't want to refresh all of the requested data, since some of it doesn't need to be refreshed as often and some not at all (for example a list of countries).
So what I need is a way to tell vuex wheter i want to save the response of a specific axios request forever, or to re-request it after a set amount of time.
My questions are: Is there a plugin for this that I couldn't find? And if not, how could i implement the described functionality without rewriting it for every request?
There are some axios cache projects available:
axios-extensions (LRUCache)
axios-cache-adapter (localforage)
cachios (node-cache)
The 2 most popular currently are axios-extensions and axios-cache-adapter
Source of the chart
There is a library axios-cache-adapter that is a plugin for axios, to allow caching responses.
It is a great solution for implementing caching layer that takes care of validating cache outside of application's data storage logic and leverages it to requets library instead.
It can be used with both localstorage and indexedDB (via localforage library)

how to use MethodAuthorizer in Restlet?

I'm currently working on a project with Restlet API.
Now, my router routes 6 different URI's to 6 different Resources.
What i want to do is only to restrict DELETE and PUT methods in 2 of my resources to only authorized users.
I couldn't find any example or tutorial that i can learn about MethodAuthorizer. Is there any easy way to do this?
I tried to use the MethodAuthorizer the same way we can use the RoleAuthorizer (explained here - see the sample code at bottom of the page)
Router router = new Router(getContext());
router.attach("/your/path", YourResource.class);
MethodAuthorizer ma = new MethodAuthorizer();
ma.getAnonymousMethods().add(Method.GET); // your allowed method for all user
ma.getAuthenticatedMethods().add(Method.DELETE); // your allowed method to authenticated user
ma.setNext(route);
rootRouter.attach("/admin", ma);
But it doesn't seem that it is the way to go :(
However if you take a look at the workflow of the security API, I shouldn't be to far from the solution.