GQL Modules - GraphQL Modules for Remote Client Browsers

It does not use that Report until later on. It is not important right now.

The getUser(PIN) query is supposed to return data about the User whose PIN matches. Your query is not returning anything - it is empty basically (“data” has nothing in it). The response should not be empty; it should look like this:

{
  "data": {
    "user": {
      "name": "Ovania",
      "userRole": {
        "name": "Manager",
        "isAdmin": false
      }
    }
  },
  "errors": null
}

What version of SambaPOS are you running?

No idea why it is not returning data. Look for other graphql responses to see if you can find any error messages.

5.1.62 Didn’t realize it been 2-3 months old. I will update and report back.

Got name * no matter which pin

{
  "data": {
    "user": {
      "name": "*"
    }
  },
  "errors": null
}

Ok that’s better.

I deduced the * means that it could not find a user with that PIN. That’s why the validateUser() function check for that.

I get the same result when I use a PIN that does not exist…

{
  "data": {
    "user": {
      "name": "*",
      "userRole": {
        "name": "Default UserRole",
        "isAdmin": false
      }
    }
  },
  "errors": null
}

P.S. I am running 5.2.2 … I wonder if that matters? It might… hmmm… probably.

getUser() might not return the Role information in 5.1.62. That might be where the error in the JS code is complaining about.

Damn. Implemented that change in the Query too quick.


EDIT: nope, not the problem. Version 5.1.62 should still work.

update to 5.2.2

Got a liitle different

{
“data”: {
“user”: {
“name”: “*”,
“userRole”: {
“name”: “Default UserRole”,
“isAdmin”: false
}
}
},
“errors”: null
}

Hmm what is wrong…

Pin 1234 return qpos

That’s better, but I checked all the code, and nowhere do I try to access userRole.name so the error cannot be coming from that. So 5.1.62 should still work (yay!)

Again, the "name": "*" means it cannot find a User with that PIN.

Try running the Query through GraphiQL interface to see what you get. If you still get "name": "*" then there is some other problem.

{getUser(pin:"1234"){name}}

Show me your config.js file. Do you have hard-coded users in there? Not that it should matter.

###config.js

// set default Terminal, and optionally User and Password to use ONLY if Authentication is Bypassed (see config_auth.js)
var defaultTerminal = 'Server'; // Terminal must be defined in SambaPOS
var defaultUser = '';           // Set this ONLY if Authentication is Bypassed (see config_auth.js)
var defaultUserPassword = '';   // This is the account PASSWORD, not the PIN.  Set this ONLY if Authentication is Bypassed (see config_auth.js)

// static settings for Terminal and User, will be overwritten if Authentication is Activated
var currentTerminal = defaultTerminal;
var currentUser     = defaultUser;

Try a hard-reload too…

I just add defaultuser after I can’t login

// set default Terminal, and optionally User and Password to use ONLY if Authentication is Bypassed (see config_auth.js)
var defaultTerminal = 'Server'; // Terminal must be defined in SambaPOS
var defaultUser = 'qpos';           // Set this ONLY if Authentication is Bypassed (see config_auth.js)
var defaultUserPassword = '1234';   // This is the account PASSWORD, not the PIN.  Set this ONLY if Authentication is Bypassed (see config_auth.js)

For non-exist pin

Did that, but still not working.

Here the 1st screen:

Enter User and Password (not pin) then got this screen:

Then enter PIN (not password) but not going anywhere.

Remove default User and Password. Set them to empty.

Do hard-reload.

Can you verify one more time in the Network Tab, that the Request Payload is sending getUser with pin:“1234” and that the response is name:"*"

Scroll to the bottom of the request list, highlight a graphql request, and select the Headers tab.

Use arrow UP key to move upward in the request list until you see request for getUser, then switch to Response tab.

Now working. Maybe combination of default User and hard reload did the job.
Thank you so much @QMcKay.

Will start explore more tomorrow.

COOL.

You’re welcome.

It is a pretty cool system if I do say so myself. :wink:

Good night :stuck_out_tongue_winking_eye:

Where to set Entity Screen for POS module? I can’t find it.

{
  "data": {
    "entityScreenItems": null
  },
  "errors": [
    {
      "ClassName": "GraphQL.ExecutionError",
      "Message": "Error trying to resolve getEntityScreenItems.",
      "Data": null,
      "InnerException": {
        "ClassName": "System.ArgumentException",
        "Message": "Entity screen not found",
        "Data": null,
        "InnerException": null,
        "HelpURL": null,
        "StackTraceString": "   at Samba.Services.Graphql.Entities.EntityQuery.GetEntityScreenItems(ResolveFieldContext arg) in C:\\Users\\emree\\Documents\\Github\\SambaPOSPro\\Samba.Services\\Graphql\\Entities\\EntityQuery.cs:line 112\r\n   at GraphQL.DocumentExecuter.<ResolveFieldAsync>d__8.MoveNext()",
        "RemoteStackTraceString": null,
        "RemoteStackIndex": 0,
        "ExceptionMethod": "8\nGetEntityScreenItems\nSamba.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\nSamba.Services.Graphql.Entities.EntityQuery\nSystem.Collections.Generic.IEnumerable`1[Samba.Services.Common.ViewBase.Entities.EntityScreenItemViewModelBase] GetEntityScreenItems(GraphQL.Types.ResolveFieldContext)",
        "HResult": -2147024809,
        "Source": "Samba.Services",
        "WatsonBuckets": null,
        "ParamName": null
      },
      "HelpURL": null,
      "StackTraceString": null,
      "RemoteStackTraceString": null,
      "RemoteStackIndex": 0,
      "ExceptionMethod": null,
      "HResult": -2146233088,
      "Source": null,
      "WatsonBuckets": null
    }
  ]
}

var POS_EntityTypes in config_modules.js


Or if you set POS_EntityTypesAuto = true then it will try to pull the Special Report GQLM Ticket Type Entity Types to determine the Entity Types assigned to your Ticket Type.

I have Tables and Customers Enitity Type and POS_EntityTypesAuto = false
But I got erroe Entity Screen Not Found. I thought it looking for specific Entity Screen Name.

Yes, it is looking for Entity Screen Names, not Entity Types.

The variable name is old, before we had getEntityScreenItems() query, we had to get Entity Types. But now we get Screens instead. I need to change the name of the variable.

I changed screen name to “Customers” and “Tables” and get past error but it stop (keep spinning, Loading Module [POS] Please Wait…) after this query.
{ "data": { "menu": { "categories": [ { "id": 4, "name": "Main Menu", "color": "Orange", "foreground": "Black", "image": null, "header": null, "menuId": 1, "isFastMenu": true, "menuItems": [ { "id": 39, "name": "Lunch", "color": "Green", "foreground": "White", "image": null, "header": "Lunch", "caption": "Lunch", "categoryId": 4, "productId": 0, "portion": null, "quantity": 1, "defaultOrderTags": null, "product": null }, { "id": 40, "name": "Dinner", "color": "Green", "foreground": "White", "image": null, "header": "Dinner", "caption": "Dinner", "categoryId": 4, "productId": 0, "portion": null, "quantity": 1, "defaultOrderTags": null, "product": null }, { "id": 41, "name": "Drinks", "color": "Green", "foreground": "White", "image": null, "header": "Drinks", "caption": "Drinks", "categoryId": 4, "productId": 0, "portion": null, "quantity": 1, "defaultOrderTags": null, "product": null } ] } ] } }, "errors": null }

There must be an Error Message somewhere. It would not just return the Menu and stop functioning without letting you know something. Check the Console.


EDIT: Remember too that if you change certain things in SambaPOS you might need to restart the Messaging Service, and if you change things in the JS code, you probably need to do a hard-reload of the code so it is not using a cached version.

Once your configuration is working properly, restarts and hard-reloads won’t be necessary.

Another note on this Entity Types vs. Entity Screen Names thing…

Right now, the code sort of uses them interchangeably. That is, it expects the Screen Names to be the same as the Entity Type Names.

This is something that was somewhat short-sited, but at the same time, it was also because of new features in SambaPOS GQL that came about after initially implementation.

As is the case in my system, my Entity Screen Names (ie. “Customers”) happens to be the same as as my Entity Type Names (ie. “Customers”).

I have not pursued “fixing” this in the code unfortunately, at least not yet.