Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by dadish

  1. Well now I am embarrassed. So sorry. It turns out upgrading to the latest graphql library broke some stuff. For some reason I did not check the queries without the selectors. I made some fixes. This should solve your problem. Please get the latest version and try again.
  2. Hi @abdus. You are good to go actually. The argument is required only when there is an exclamation mark after it. It does not have to be = false. Sorry for the confusion, the way I explain it in screencast is a bit misleading. To sum it up, if there is an exclamation mark "!" at the end, it means it is required, of not then it is optional. The = false part means, the default value is false. I know, it sounds stupid. It was a bug in the library I used for this module. I updated it to the latest version since the screencast and now it shows correctly. The = false part is actually is a bug in older version of the module. You probably installed the latest version which shows correctly. So, your version is actually is the way it supposed to be. The version in the screencast is a bit misleading, but still correct.
  3. Unfortunately not yet. I am planning to implement them. But I am a bit busy now and it would definitely take some time to implement it. For now, you will have to do it some other way. Sorry
  4. Yes. It was my bad. I did not make sure the FieldtypeCheckbox always returned a boolean. I think it returns 0/1 in ProcessWire. Anyways, just patched it. Update to the latest version and it should work. Edit: As always, thanks for the feedback.
  5. Yeah, I had my nightmares with this situation too. There are lots of scenarios when ProcessWire could redirect your ajax requests and the graphql will not receive the query. The ones that I had encountered were: If the url ends without slash: ...website.com/graphql ==> ...website.com/graphql/ If there is now www prefix: website.com/graphql/ ==> www.website.com/graphq/ And now I guess when languages are enabled you also gotta make sure ProcessWire is not redirecting you to the respective language url of the graphql api. I haven't tested the module with the languages enabled yet, but I am sure there would be some additional caveats. Yes, that's the expected behavior. Unfortunately to support permission inheritance would be too expensive. Because it means to check template permissions of each ancestor of each returned page. I think the module is already slow and supporting permission inheritance would make it even slower. I guess I have to mention about not supporting permission inheritance somewhere in the documentation of the module. That's right, it turns out there was a bug. I pushed an update regarding the datetime field. Grab the latest version of the module and it should work properly. Yep. That's the way. I know, it's ugly. But I can't think of a less verbose way to return a single page from the api. We could, of course introduce an additional field for each template like basic_page_single or something. But I don't think it's worth it, plus it will make the schema bigger for very little gain. I totally agree. We can't allow everyone to create images. The size field of the image type creates images only if the user has an edit permission on that image field. It is still available to the users who do not have edit permission, but only for getting existing variations, and it should return null if there isn't an image variation with the requested size. Edit: By the way, thanks a lot for the feedback.
  6. Sure, by all means. Thanks. I am glad you like it @Soma.
  7. Thanks @adrian! I rerecorded the video many times before I could make it watchable. Trust me, you wouldn't say the same thing for the very first ones About the field access rules. Yeah that's true. By default the behavior is the opposite to the one in ProcessWire. I think it would be better for security if the module initially treats everything private. But I get what you mean. In cases where you have dozens of fields in one template, it would be too tedious to configure access for each of them. That's why there is an option to reverse the behavior in the advanced section of the module configuration. You can learn more about it here. This option basically makes all fields without Access rules available to the public and you can restrict access by enabling rules only to couple ones.
  8. Hi @mvdesign. So sorry that I could not respond earlier. I decided to make an introduction video for this module to help people that are trying to use it. But then, I never made a screencast video before, and on top of that, the last time I spoke english was 2011. So I had to take dozens of try-outs till I got something watchable. So here is the video. It shows how you would create/update pages with this module. The video is far from OK, so I will probably record another one after I get some feedback. Until then please refer to this video to learn about how the module works.
  9. I am happy it works now . The plan is to add support for all core fieldtypes. That includes RepeaterField also. I will try to keep everyone updated via this thread, and you can also keep with the changelog.
  10. No, it's not the permissions. You're doing everything properly. I never tried this module with axios before, therefore this error is new to me. It turns out that axios sets the Content-Type header to application/json;charset=UTF-8 instead of application/json. That's where the problem was, because the ProcessGraphQL module would parse json payload only if Content-Type was set to just application/json. I changed the behavior and now it will look to your query in json payload if Content-Type contains application/json string in it. Please grab the latest version of the module and try again. It should work now. Thank you for taking time to report the issue.
  11. Thank you @teppo! I knew I can count on you!
  12. I agree with you on that. I think it would be best if we move this thread to modules section. So, please move it to the modules section. Then after I will update my first post of this thread a bit and add a module tag I guess
  13. I am happy that you like it @Sebastian, thank you for your support. I started the thread here because I thought this would be more like a discussion on how GraphQL and ProcessWire could fit together and wanted to get some feedback first. But this thread quickly become this module's official place here in the ProcessWire forums. Also @teppo included the link to this thread as the "dedicated support forum thread" in the 143 issue of the weekly.pw (which I was flattered to see ). Now I don't really know how to go on with this thread. Should we abandon it and start new thread in the modules section? Or maybe this thread could be moved to modules section? What @moderators think of this? Meanwhile, for those who are following this thread I wanted to mention that there are some additions in the dev branch, such as mutations that allows you to create/update pages and there is also support for FieldtypeMapMarker field. I stopped developing the module for some time because I thought that it needed a good testing before moving further with it and decided to built an SPA using this module, to see if there is something that need to be added or changed. But then I got carried away and started to make usage of third-party APIs such as Wikipedia and GoogleMaps. As a result the app does not make heavy usage of the ProcessGraphQL module, but it is still relevant to showcase the module's abilities. It is a US Skyscrapers app, duh... You can see it live here and the source code here (though I doubt that the code will interest you if you are not a React developer). I was finished with this demo SPA just couple of days ago. Now I will be back to continue to work on this module again.
  14. Hey @bcartier and everyone who is following. I implemented a basic language support. Nothing really changed, except now with LanguageSupport enabled in your ProcessWire app, the GraphQL api will return the content in whatever language the user is assigned. In addition, when Language Support module is activated, there is a language field in your GraphQL api. So you can request the exact language you want. It looks like this. { language(name: "de") basic_page{ list{ title summary } } } You need to put the language field on the top. Well, not exactly on top but just before fields that return translatable content, like title, headline, body etc. It's because GraphQL processes requested fields from top to bottom and it will not know what language you want till it gets to language field. Did you also know that in GraphQL you can query same field multiple times with aliases? Here, take a look at this { basic_page_default: basic_page{ list{ title summary } } language(name: "de") basic_page_de: basic_page{ list{ title summary } } } Curious what will be the response? Try this with site-languages profile and find out.
  15. No there isn't at the moment. There will be support for it of course. The way it will work is if the user has a view access to the image field she will be able to fetch all the available image information, including the thumbnail variations. For user to be able to create thumbnails herself, she will need an edit access for that field.
  16. @Oliver, @bcartier Thanks guys. Glad you like it. No, Language fields are not supported yet. There will be support for them too. Maybe I will implement them this weekend. In any case I will let you know when they are available. For those who are following this module, I make releases almost everyday. Sometimes I introduce new bugs but patch them as soon as I find them. There are bunch of features added since the first introduction. You can follow up the changes/additions in the changelog. Lots of parts are not documented yet but I will provide full documentation and possibly introduction video targeted to ProcessWire users, on what the module is about, how you can use it, along with some todo app tutorial. But for now, feel free to play with it and provide some feedback either here or in issue tracker. It is always easier to make changes in the beginning.
  17. Hey @zota. I made some changes on how the GraphiQL assets are loaded in the admin interface. Before that it was a quick stupid hack, sorry. Now it is as it supposed to be loaded for Process modules. I don't know why I didn't do it from the start. Please remove the old version and install the latest from repository. The error you are getting will most likely go away.
  18. Just to make sure. Is this a PHP error, or is it a JavaScript error in your browser console? Could you also give some environment details. Which version of PHP, ProcessWire?
  19. Thank you @Werner Pilnei. I am excited because I like using ProcessWire . I try to do my best in introducing this module to the community. GraphQL is very young standard and is not mainstream yet. I intentionally started this thread in the Pub section, to make sure this is not a module support page but more a discussion on GraphQL (as this new api standard by facebook) and ProcessWire. To talk about how they could fit with each other, what ways we could use it, the new ways to use ProcessWire and so on. I personally never think about ProcessWire as a CMS. Though it is in fact a true CMS in its literal meaning, it is best at managing your content. But when people are introduced to ProcessWire it is presented as CMS and since the web is cursed by WordPress, people start using ProcessWire with wrong assumptions in their minds which result in negative impressions. I am generalizing here but when an average web developer hears CMS, she thinks it is a ready website with bunch of functionality baked in like tags, searching, blogging, commenting and so on. Those functionalities become the evaluation criteria and when they see that there is no tags in ProcessWire they count that as one of the things ProcessWire is missing. They don't understand that tags are something ProcessWire shouldn't have, because they are used to see tags in a CMS. I don't think that I am telling something new here. The community is well aware of this problem and the release of new site profile states that these problems are being addressed. But it doesn't have to be the only way. The modular architecture of ProcessWire allows us to extend it anyway we want, and this module is one of those attempts in presenting ProcessWire in different perspective. Even if it won't make much difference, I think we should keep trying and experimenting. Who knows what could come up along the way. I was only thinking about SPAs when creating this module. Never thought of PWA and usage with service workers like you approached it. Which is, by the way is great to hear. I hope there will be bunch of other ways people use it.
  20. That will all depend on how you configure your api. If you wish this module can expose all pages in your website, including the system ones. Or you can restrict to some very limited data. There are more functionality to come, but at this stage the module supports: Template restrictions. You can choose which templates are enabled, but in addition it will conform to ProcessWire permissions. So you could limit access to certain templates only to certain user roles. You can enable access to only logged in users for example. Field restrictions. Also supports ProcessWire permissions. Including template context permissions. Meaning, you can allow title to be viewable for one template and restrict for another. Max limit support. Like the one you use in selectors. So users won't be able to get list of data for more than say 50 pages at a time. and also many other security options are on the roadmap: Built in field restrictions. At it's current stage api gives access to page fields like children, parents, createdUser..., or there are path, size, basename for files and images fields. Those will be disabled and available as extras. Query complexity limit. Currently you can build queries as deep as you want, to request ridiculous amounts of data. This will also be limited for only couple levels of complexity and you will be able to increase or decrease it.
  21. Hey there @bernhard! I am happy people like it. To make an AJAX request to your GraphQL api, you need to send a query variable that describes what you want. You should've seen how the query looks like in the first post of this thread. To send the query you can use any of your favorite AJAX libraries. Here is how it looks like in jQuery. $.post( '/graphql/', // this is the url where your GraphQL api is exposed. { query: "{ skyscrapers { list { title } } }", // this is your query, this one requests the skyscrapers and title field for each of them. }, function (res) { console.log(res); } // here you do whatever you want with the returned data ); Or if you prefer to communicate with your api in application/json, you can do that too. Here is how it looks like in my favorite AJAX library - superagent. superagent .post('/graphql/') .set('Content-Type', 'application/json') .send({ query: "{ city { list { title } } }" }) .then(function (res) { console.log(res.body); }); PLEASE NOTE: When making requests to your api make sure the url is pointing where it is supposed to. The request will not work if you omit the trailing slash. With default settings the request to /graphql won't be processed by ProcessWire but instead redirected to /graphql/ and the ProcessGraphQL module will not receive the query parameter you sent. Same might happen with leading www. prefix. The request to http://example.com will be redirected to http://www.example.com which will also loose the query parameter in the middle.
  22. That's right. That's the way it will work when module is done. Currently there is a support for template permissions. Support for Field permissions are on the way, I am working on it but it will take some time. For now you can limit the fields via module settings, I pushed support for legal fields two hours ago. Thumbs up from @horst ! Yeeeey I am a big fan of your modules!
  23. Ooh, that's right. Now I get what you mean. Thank you for clarifying that for me. That's true, with this module it gets available to the public without echoing it explicitly. So you will have to setup extra permissions to make it closed to the guest user. This was the initial intention of this module really. The goal is to build a tool that will allow you to quickly bootstrap an AJAX api of your ProcessWire content to build SPA out of it. For cases like you guys describe, this module might have some drawbacks. But you could always cook your own GraphQL api and make it behave however you want. It's fairly easy after you learn a bit about it. Here is the library I use for this module.
  24. There is not need for different endpoint for users with different roles. The module does not have any authentication/authorization logic on it's own. The users that will be able to authenticate with this module are the same users in your ProcessWire installation. When I mentioned implementing authentication, I was talking about logging in via GraphQL api, like via AJAX. In reality it will be the same $session->login('username', 'password'), nothing more. No, no. Of course not. I am sorry for the confusion here. Legal templates mean legal for the api. It does not mean it will make it available to the public. Like I mentioned earlier the module checks if the requesting user has permissions to view, edit, create and etc. If say you select user template as legal. It does not mean it will be public. It means it is available via api to those who are authorized to view it, authorized via ProcessWire's access control system. I personally don't think there is even a need for the legal templates option. But it is helpful if you have too many templates and selecting only few can reduce the schema size and make api faster. I think there is a bit confusion about this. I want emphasize that this module does not make any data public, nor does it anything private. That is not the module's concern. The module's job is to make your data available in a JSON format, in addition providing the ability to consume that JSON data via GraphQL api. If the user does not have permissions to view a certain page according to ProcessWire's access control system then he won't be able to fetch it. The same goes for fields. When implemented the user will be able to access only those fields that he is authorized via ProcessWire's access control. But I will add an option for legal fields also, because that also could help reduce the initial schema size.
  25. But all you said is already can be achieved. No need to do anything on my side. Maybe add documentation on module's properties though. You can modify the module settings via api by overwriting them. So here how you can set different templates for different endpoints. // /site/templates/graphql-endpoint1.php <?php $ProcessGraphQL = $modules->get('ProcessGraphQL'); $ProcessGraphQL->legalTemplates = array('skyscraper', 'city'); echo $ProcessGraphQL->executeGraphQL(); ?> // /site/templates/graphql-endpoint2.php <?php $ProcessGraphQL = $modules->get('ProcessGraphQL'); $ProcessGraphQL->legalTemplates = array('architect', 'basic-page'); echo $ProcessGraphQL->executeGraphQL(); // /site/templates/graphql-endpoint3.php $ProcessGraphQL = $modules->get('ProcessGraphQL'); echo $ProcessGraphQL->executeGraphQL(); // here it will use default settings that you set via admin interface For the ability to distinguish the versions of your GraphQL endpoints. That's also doable without much effort. We are talking about ProcessWire after all. Here how it might look like. $config->GraphqlEndpointID = 123; echo $modules->get('ProcessGraphQL')->executeGraphQL(); $config->GraphqlEndpointID = false; And same thing in other template files with different endpoint id. Now anywhere you attach a hook, you can know which endpoint of your api is being executed, or if it is being executed at all. You just need to add a conditional block in your hook. Something like if (wire('config')->GraphqlEndpointID === 123) { // some bussiness here } I am a bit confused though. One of selling points of GraphQL is that there is only one url that you need to deal with. It's just `example.com/graphql/` and nothing more. No more this GET example.com/graphql/skyscrapers/ GET example.com/graphql/skyscrapers/{id} POST example.com/graphql/skyscrapers/ PUT example.com/graphql/skyscrapers/{id} PATCH example.com/graphql/skyscrapers/{id} GET example.com/graphql/architects/ ... It's only one endpoint for everything you need. That's actually is the way it is encouraged to build GraphQL api. Also it is only one HTTP verb you need to use, which is POST. You can stop thinking about dealing with PUT, PATCH, HEAD, OPTION and more. You only need this with GraphQL. POST example.com/your-endpoint-url/ And that's it. One HTTP verb and one url to rule them all .
  • Create New...