Jump to content

dadish

Members
  • Posts

    110
  • Joined

  • Last visited

  • Days Won

    8

dadish last won the day on November 19 2019

dadish had the most liked content!

About dadish

  • Birthday 03/15/1987

Contact Methods

  • Website URL
    https://nurgulyashyrov.com

Profile Information

  • Gender
    Male
  • Location
    Turkmenistan

Recent Profile Visitors

2,656 profile views

dadish's Achievements

Sr. Member

Sr. Member (5/6)

454

Reputation

  1. Or in other words, it would force people to use a predefined method of authentication, instead of allowing them to use their own preferred version. Some people may prefer JWT tokens, others might want cookie based auth or maybe people need to use third party authentication like AWS Incognito..., the list goes on.
  2. I would prefer people implement their own authenticaton/session flow. The thing you describe above should be simple to implement with the ProcessGraphQL::getMutationFields hook. I think I will remove the login(name: "name", pass: "pass") query field in the future and add a clear documentation/example on how you could implement your own authentication flow. Thanks a lot for the idea @Tom.. I think it would be more flexible this way.
  3. You can do it manually on the ProcessWire side. Before returning the result to the client, simply do the JS trick that you posted in PHP and return the result to the client.
  4. Hey Tom. What do you mean "using Node JS server?" Do you mean where the JavaScript files coming from? If that's your question, then it should not matter. It does not matter where the javascript files are coming from. I did a little research and found out that it works in Firefox but not in Chrome. I don't use Chrome, that's why I couldn't reproduce your issue. Have you tried the above JS code in Firefox? If not please try it out and tell me the results. If that works then we will work on fixing it for the Chrome browser.
  5. Haven't tried it, but something like this should work. https://webonyx.github.io/graphql-php/getting-started/ Scroll down to the first example and see how fields are defined in GraphQL. In your case it should look similar to this. <?php $fields[] = [ 'name' => 'intro', 'type' => Type::string(), 'resolve' => function ($page) { return $page->intro; } ]; Play around with it and you'll get there.
  6. No problem. Sorry for not answering sooner. I used fetch api. Just like you. Sure. I created a sample app with create-react-app. Then I start the app with `npm start`. And here is my App.js file. const query = async (query) => { const res = await fetch("https://skyscrapers.nurgulyashyrov.com/graphql/", { method: "POST", credentials: "include", headers: { "Content-Type": "application/json", Accept: "application/json", }, body: JSON.stringify({ query }), }); const json = await res.json(); console.log("json", json); }; const execute = async () => { await query(`{ logout { statusCode }}`); await query(`{ me { name }}`); await query(`{ login(name: "name", pass: "pass") { statusCode } }`); await query(`{ me { name }}`); }; execute(); function App() { return null; } export default App; Note that the app starts a server that runs on http://localhost:3000. If you are testing by simply opening a file in the browser then it will probably not work. So you need your browser address bar to start with http(s):// and not with file:/// EDIT: You will have to substitute the url with your own, of course. The graphql api is setup exactly as in my previous post. I assume you noticed that the CORS headers are inside the cors() function and that you have to call that function before final response.
  7. Here is the CORS setup that works for me. <?php // https://github.com/dadish/ProcessGraphQL/blob/622c9db61cb7cf3ef998edb31e4e0e47b3c96669/test/server.php#L20-L43 function cors() { // Allow from any origin if (isset($_SERVER['HTTP_ORIGIN'])) { // Decide if the origin in $_SERVER['HTTP_ORIGIN'] is one // you want to allow, and if so: header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}"); header('Access-Control-Allow-Credentials: true'); header('Access-Control-Max-Age: 86400'); // cache for 1 day } // Access-Control headers are received during OPTIONS requests if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') { if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) // may also be using PUT, PATCH, HEAD etc header("Access-Control-Allow-Methods: GET, POST, OPTIONS"); if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}"); exit(0); } } Could you try it and let me know if it solves your problem with different domains?
  8. Probably because there are some conditions that are required. One of those things is that in order for user to be able to create a page they require a `page-create` permission for the template that is going to be created, but also `page-add` permission for the template that will be a parent of the created page. You could probably achieve this by just removing some mutation fields with hooks. Should look something like below. <?php $wire->addHookAfter("ProcessGraphQL::getMutationFields", function (HookEvent $event) { $fields = $event->return; $newFields = []; foreach ($fields as $field) { if (!in_array($field['name'], ['updatePost', 'updateComment'] )) { // list the name of mutation fields you want to disable $newFields[] = $field; } } $event->return = $newFields; }); Make sure this code is run before the module has responded to the query. Before $modules->get('ProcessGraphQL')->executeGraphQL() Thanks. Will update. 👍
  9. Login should work as regular processwire login flow. Just do a first request as { login(name: "username", pass: "password") { statusCode } } Then all subsequent requests from the browser will automatically include the processwire cookies.
  10. @markus_blue_tomato I assume job_group is a page field. Page fields in GraphQL return Page interface that has only built-in fields (id. name, url...). If you want to get custom fields like (title, job_group_id...) you need to use fragments. { jobDetail { list { id job_name job_group { list { id name ... on JobGroupPage { // <== you need to use the actual type name here title job_group_id } } } } } }
  11. Make sure you have rights to see it in insomnia. You probably not authenticated in insomnia, which means you're a guest user and those fields are not configured to be accessible by the guest user. Can you check if my assumptions are correct?
  12. Hi @markus_blue_tomato. Do you see your fields in PW admin? At Setup -> GraphQL page?
  13. New Release v1.3.0 Adds support for Page interface. Updates webonyx/graphql-php to the latest version. Adds hook that enables to modify the GraphQL schema. (#26 @sebastiandittrich) Fixes error when creating/updating a page with DateTime field. (#28 @sebastiandittrich) @sodesign Not sure if you still need this but this release brings support for interfaces that I previously talked about. Hope you'll find it helpful.
  14. You can add support for Repeater Matrix Fieldtypes via custom third-party modules. Refer to documentation on how you can create one. https://github.com/dadish/ProcessGraphQL#third-party-fieldtypes-support
  15. You need to use the language field. In your graphql endpoint there is a language field. So it will look like { language(name:"<language_name_here>") test { list { testtext } } }
×
×
  • Create New...