Building a Service



In this video we show how you can build a GraphQL API to expose data in a SQL database.
 
--- LINKS ---
 
Free Community Edition Download
 
Alpha Software YouTube Channel
 
Documentation
 
 
 
#graphql #api #mobileapp #app #ui #android #ux #ios #mobileappdevelopment #appdesign #uidesign #mobileapps #appdevelopment
 

Transcript

in this video we're going to discuss how

you can create a growth QL service that

exposes data in a sequel database so you

can see that we're gonna go here to the

web control panel

and we're going to choose the web

services category and then I'm going to

go ahead and click on the new button and

I'm going to choose great new definition

to create a growth ql service and that's

going to open up the define graph QL

service dialog so the first thing that

we need to do is specify the connection

string to the database so I'm going to

go ahead here and click on change

connection string and I'm going to

choose sequel server Northwind so this

is a sequel server database that has the

tables from the Northwind database in it

so I'm going to go ahead and be like ok

and now that I've done that I can pick

which tables from this database I'd like

to expose in the service so we click

this button the hyperlink here and this

opens up a list of all the tables in

that database so I can go ahead here and

choose say the customer table the

employee table order detail orders

product region category let's go then go

shippers supplier territory I guess that

should that should be enough and then

you can see we can also basically create

custom views so a custom view is just

one of the tables from the database with

a where clause that limits the rows that

can be returned by the query and also

limits the number of columns that can be

returned by the query so right now we're

not going to basically define any custom

views so I want to just go here then

click Save so at this point I'll be

anyway is getting the schema of that

database and once it's got the schema

it's going to fill in the service

definition so it can take a couple

seconds to get the database schema

depending on the size of the

debase so here is the schema which

defines the growth QL server so you can

see that basically we have an array of

tables this is all of the tables that

are exposed by the service so for

example he has the that cat the table is

called category the plural version of

the table name is categories the actual

name of the table is categories so

category here is an alias for the actual

name which is categories and then over

here we're defining what type of queries

all mutations can be done so based we're

allowed to do a query against this

customers table we're also allowed to do

inserts updates and deletes and then you

can see over here is a list of all of

the fields that are going to be returned

that that can be that can be returned

from the query and then for each table

we can specify what the children of that

table are so these are the one-to-many

relationships that are available for

that table so for example for the

categories table you can get a list of

all the products in their particular

category then with the go down say to

the customer table we can see how that

the children of the customer table are

orders then if we go to the employee

table we can see that the the children

of employees are also the employees

table so this is a self referencing

table and then orders and then if we go

to order details we can see that

basically that there's a join here so

these are joins or one-to-one

relationships so that means that each

order detail record is joined in a

one-to-one relationship to the order

table and also to the product table so

we can now go ahead and just press the

Save button to save our new service

definition so we'll go ahead here and

we'll call this

draweth ql1 and then go ahead and hit

the Save button and you can see we now

have a new service to find here in the

web control panel