GQL Modules - GraphQL Modules for Remote Client Browsers

No. Provide the Version number of SambaPOS. Upgrade to the latest.

And your questions have nothing to do with this Topic. Make a new Topic.

Hey guys im having some issues trying to get these modules working. basically i get the following screenshot


and the token states “Invalid clientId” however looking at the config.js file. Specifically the GQLclientId part

and sambapos application side…

as far as I can see the client id matches?

I tried to login to GQL also and I receive a successful token… but not for the GQLmodule client id.

any idea where I’m going wrong?

Did you follow these instructions to modify the code? The error indicates the clientId was not even sent.

You also need to restart the Message Server Service after adding an Application.

P.S. I really need to update the Github soon :wink:

Yes rather in importing all the rules and what not i decided to manually implement everything line by line but since i scroll back and forth a lot to ensure i dont miss anything, that assurity habit of mine might be causing me to miss something haha.

The code on github was all done during .60 and .61 but the modification part to config.js and other .js files were not updated and i did scroll down to ensure i didnt miss any updates(knowing how long its been since you made this) and i found the updated code and put it alongside the code i downloaded, then i put whatever additional coding that was required in and saved it.

I didnt restart message server however i did restart my pc so i believed that by doing so it may also restart the message server. After restarting the pc i tried again and it still wouldnt give me an access token for gqlmodules.

Out of curiosity if you have multiple applications setup for gql, would the additional applications interfere with the login process?

Im not at my pc right now but i do remember i had 3 applications setup.

1.graphiql
2.mobilepos(for the android application im testing.)
3. GqlModules(for the web based application for this tutorial)

I also setup an individual user for each application to test with,however everytime i do login to gql it only always creates a token for graphiql client.

I wonder if sorting them applications would make a difference. That is if i bring the gqlmodule to the top and see if that makes a difference.

Once i get back to my pc ill upload screenshots of each file that required modification and paste the code for better viewing.

No. The Application is to set the Client Id. The Login is done via Username and Password (not PIN). GraphQL requires both for Authentication.

For the GraphiQL interface, that Web App is hard-coded with the Client Id (Identifier) as graphiql so you need to set up that Application in SambaPOS exactly like that for it to work. The Username and Password can be anything. But this has nothing to do with GQL Modules …


I see the error you are getting, but we need to see the Post Request (Form Data) to ensure it is sending the proper information. In Chrome, that will be in the Headers Tab, and the request is at the bottom …

#UPDATE: 2017-06-03

GitHub Repository has been updated.

##Updates for GraphQL Authentication for SambaPOS 5.1.62+

GraphQL requires Authentication from Apps as of v5.1.62. This involves configuring an Application in:

Manage > Users > Applications

##Application Configuration

For GQL Modules you can identify the Application however you want, but you need the Client Id (Identifier) in SambaPOS to match GQLclientId variable in config_auth.js

###SambaPOS Application Configuration

It is also important to note that GraphQL Authentication is able to determine if the App is trying to access the engine on the Local Network, or from another Network such as the Internet. So you need to properly set the Authorization Type in SambaPOS to coincide with the type of access you are trying to provide. Note in my previous screenshot for setting up the Application, I have the Auth Type set to All Functions. This means I can access GraphQL from an App (GQLModules) from outside the Local Network, that is, from a remote location on the Internet.

###GQL Modules Configuration (config_auth.js)

Set the variable for GQLclientId in config_auth.js so that it matches the Application Identifier configured in SambaPOS. You can also set the GQLsecret variable if you configured an App Secret for the Application in SambaPOS. The variable for GQLappPassword should be left empty so that you will be prompted for this information using the Login Forms.


##Configure an Application User in SambaPOS

Create a User in SambaPOS that you will use for GraphQL Authentication. Be sure to have a strong Password for this User.


##App Authentication and PIN Login

This update includes Login Forms to prompt the operator for the Username and Password to Authenticate the App, and it has a 2nd prompt for a User PIN to identify which SambaPOS User is using the GQLModules App. The PIN Login has nothing to do with GraphQL Authentication. These are separate things …


##Cached Auto-login

Both the Application Authentication and PIN Login are cached in Browser Storage so the next time you open your Browser, the Authentication and PIN Login are “automatic” …


##Switching User

Once you have performed App Authentication using the Username and Password, you should never need to do it again.

But there may be times when you want to switch the Registered User. For example, if you are using the POS Module, you might want to change the User on a Tablet so the Users Tickets are properly tracked. This can be done by Logging out, and you will be prompted for a PIN to register the User. Remember, this has nothing to do with GraphQL Authentication (that has already been done with a Username and Password); this is only to register the User of GQL Modules …


3 Likes

Ok. I downloaded the latest update, configured the clientID to match the application client ID

UPDATE: Very strange, if i access the webpage from lets say my phone or tablet connected to the same network, it works??? but on the same machine in chrome it doesnt???

*Issue 1


It could not find this report because I did not make this report under reports. Reason? In the tutorial under Special report looking at

There’s no information there. Neither is there anything for GQLM Terminals either

I initially thought maybe just create the report with those names but leave it blank. But looking at the error message, it is trying to fetch data from that particular report, so I thought there definitely must be something in that report otherwise it is odd.
I searched the rest of the topic but couldn’t find anything specific to those reports.
Any ideas?

Hmm, yeah, it is not sending the client_id. Try this to force a code reload …

Special Reports post has been updated to contain the missing Reports.

GQLM Ticket Type Entity Types
GQLM Terminals

Great! after the forced refresh now we are getting somewhere. However I came across another issue.
I get the following


In the modules I can only see the entity type which is set to default as it is in my database also. However I don’t have an entity screen named “Customers” so I’m not really sure how to filter this out or what should I do to resolve this.

EDIT Could this be because I currently don’t have any saved customer entities in the database?

That variable is an Array of Entity Screen Names.

Remove ‘Customers’ from that variable if you don’t have an Entity Screen named “Customers”:

var POS_EntityTypes = ['Tables'];

P.S. that variable is mis-named really. It used to look for Entity Types, but now it looks for Entity Screen Names. So you need to have matching Entity Screens in SambaPOS for anything that you put in that variable. If you don’t have an Entity Screen named “Tables”, but you have one named “All Tables”, then use that instead.

1 Like

Ahh yep I did exactly that just before you started typing and then restarted message server with a new refresh and it’s all working now :smiley:. This was my first attempt at doing almost anything at all to do with GQL, I’m very excited!
Thanks a lot for all your help with this :). I re-read almost every thread relating to GQL in full depth and length to really get the gist of it all and slowly getting the hang of all of this .

I do have a few questions though I was hoping to get some help with.
there are probably 2-3 things I would like to add to this “POS” screen.

  1. “Print Bill” function button
  2. Table layout display when click the “Tables”, and a way to show the Table screen first if department is set to select entity. (Not necessary but desirable)
  3. Ticket Tags and how I can show them the same way they are shown in sambapos.(Useful when Order number is used during take away orders or fast food setup)

If I know what to edit and what codes to use in which file then I can start working on possibly adding to the functionality of that POS screen.
These would be amazing to have.

That will not be easy at all. It might be possible by pulling Widget Data for Widgets assigned to the Tables screen, and based on the Widget coordinates, you might be able to layout a screen in HTML. But there is no method to “translate” a Custom Entity Screen into HTML. The getEntityScreenItems() query returns only a list of Entities with associated display formatting and nothing else.


Um, no ideas for that one.


Ticket Tags are displayed in the “Ticket List” when you Close the Ticket…

You can see that just shows Tag Values. That code is in the function POS_renderTicketList(). You can have it display the Tag Name as well …

You can also show Tags by clicking on the “Info Bar” at the top-middle of the POS Screen …

If you are wanting the Tag(s) to show in the “Order Screen” as well, it might be possible. You probably need to access the Tag(s) from the POS_Ticket.terminalTicket Object in function POS_showTicketOrders(). The POS_Ticket.terminalTicket object probably has the Ticket Tag information. You’ll need to use DevTools to set breakpoints and pause execution in that function and you can check that object content.


That is in the code somewhere already, but disabled. Print functions are part of this Array, which is Print Job Names:

var POS_PrintJobs   = ['Print Bill','Print Orders to Kitchen Printer'];

Search the module.js code for “PrintJob” and you will find the associated functions. The first occurrence shows the “buttons” commented out …

I think all you need to do is modify the Array to contain the name of your Print Bill Job, and uncomment that line.

And there are these functions, but I don’t think you need to do anything here:

POS_printJobSelect()
POS_executePrintJob()

Hmm… maybe you need to uncomment this too…

2 Likes

Sweet that’s a good enough start to get me going.
Also one thing I noticed for order tags is if you select free tagging and save free tagging, then try to highlight an item to select an order tag, nothing appears on the screen. But if you disable free tagging, you can select order tags. Is there a way we can add that free tagging into the order tag area? is there a code that allows to create order tags? if there is maybe we can use that to make the free tagging work

I don’t think there is anything in GraphQL that has that functionality.

Not sure why Free Tagging config should make a difference. Might be a limitation to the GQL Query that it ignores Order Tags that have Free Tagging set. Would have to test that to know for sure. The Query I use is:

getOrderTagsForTerminalTicketOrder()

There is another Query that is similar that I used to use, but not any longer, and the code is commented out:

getOrderTagGroups()

Yes i saw that. But what if we have a ticket tag where we would make a selection before actually taking orders. For example a client of mine has setup pax where they record how many people are at a table and they insert a number from selection all prior to ticket creation.
Im sure this hasnt been implemented yet but im wondering if there are any gql codes for it similar to the way its setup for order tags

Yes, you can set Ticket Tags using the updateTerminalTicket() mutation:

mutation m {updateTerminalTicket(terminalId:"asdfasdfasdf",tags:[{tagName:"PAX",tag:"10"}]){id,number,uid,tags{tagName,tag}}}

I can see I have that mutation in gqlqueries.js but it is incomplete because it is a “newish” mutation and I never fleshed it out yet:

gql.updateTerminalTicket = function(terminalId,note,tags,states) {
    return 'mutation m {terminalTicket:updateTerminalTicket(terminalId:"'+terminalId+'")'+gql.terminalTicketDetails()+'}';
};

It should be something like this instead:

gql.updateTerminalTicket = function(terminalId,note,tags,states) {
    var q = 'mutation m {terminalTicket:updateTerminalTicket(terminalId:"'+terminalId+'"';
    q += note ? ',note:"'+note+'"' : '';
    q += tags ? ',tags:' + tags : '';
    q += states ? ',states:' + states : '';
    q += ')';
    q += gql.terminalTicketDetails();
    q += '}';
    return q;
};

You need to ensure the parameters that you send to that function for tags and states are Arrays, like:

var someTags = ['{tagName:"PAX",tag:"10"}','{tagName:"TA",tag:"Dine In"}'];
var someStates = ['{stateName:"VIP",state:"Active"}'];

Anyway, you need to add a button somewhere, probably in the same section as the Print buttons, and when clicked have it prompt for a value and then execute that mutation.

I updated the code to use updateTerminalTicket mutation instead of updateTerminalTicket mutation. This works much better for setting Ticket Note. The old method required an existing Ticket (ie. ticket != 0) while the new method does not - it works off the terminalTicket.uid instead.

NOTE: Github NOT updated, yet, because …

I now want to expand this overlay dialog to contain more functionality. Currently it simply shows some minor Ticket Details and accepts setting the Ticket Note …

Looking for suggestions (mockups would be great) regarding how we can fill this out to provide more detail and functionality, because i don’t really need anything here for my purpose, but I’m sure others could use some more “stuff” here.

I am going to start with putting some Print Jobs in here, like Print Bill.

As of now im just brainstorming pretty much the entire code and layout to get ideas on how everything works and is connected because im very new to this world of coding haha.

But im getting a lot of the stuff written… which is a good start.

Honestly i think having ticket tags is really good to have there if defined or even if possible to be able to set free tagging and save them. So having like a dialogue box that could insert data into that ticket tag group.

But we also have to think about what if there is more than one ticket tag group.

Ticket commands. Could you give me an example of what type of ticket command?

The print jobs buttons would be really good to have as i can see a lot of staff using that feature to print bills on request.

Automation commands such as custom change price or misc item would be really good to have imho(in my honest opinion)

Maybe i could request from emre a new mutation that would allow the free tagging for order tags to allow custom order tags dialogue to work under item order tags

Edit: also some ticket tags may require selection before creating ticket. Ive looked at the code above but im curious as to which file and roughly where i woukd either update or insert that code

All I mean by that is something like an Automation Command that invokes a Ticket-level operation. Similar to a Ticket Tag but not that specific. Maybe like a Ticket Discount.

Those are Order-level operations, so they need to go somewhere else.

modules\pos\module.js

I had to change the code for Ticket Note, and Ticket Tags and States are part of the same mutation. I will take care of that in the next Git push - that’s why I’m fishing for ideas, because it could change the flow of the code.