Types & Fields
The crux of GraphQLize is generating the GraphQL types and queries by making use of JDBC metadata. This page documents the conventions and assumptions behind this automatic generation.
Type name
For every tables and views in the database, GraphQLize generates a GraphQL type. The name of the GraphQL type is the singularized, PascalCase version of the corresponding table or view name.
Table/View Name | GraphQL Type Name |
---|---|
actor | Actor |
film_actor | FilmActor |
comments | Comment |
GraphQlize supports Postgres schema. If the schema in question is not a default schema (public
), then it will be used as a prefix in the GraphQL type name.
Schema Name | Table/View Name | GraphQL Type Name |
---|---|---|
person | state_province | PersonStateProvince |
human_resources | employee | HumanResourcesEmployee |
note
The table name is alone singularized and not the schema name.
Field name
The Field names of a generated GraphQL Type represent the column names of the corresponding database table or view. GraphQLize generates the field name by converting the column name to its camelCase version.
For a table like below,
- Postgres
- MySQL
GraphQLize generates a GraphQL type as
Field type
GraphQLize supports the standard GraphQL scalar types and some custom scalar types.
During the schema generation, GraphQLize checks the column's database type and convert it to a GraphQL scalar type. Refer the table below for the type conversion mapping.
- Postgres
- MySQL
GraphQL Scalar Type | Data Type(s) |
---|---|
Int | integer , int , int2 int4 , smallint , smallserial , serial , serial2 , serial4 |
Float | real , float4 , float8 , double precision |
String | bit , bit varying , char , character varying , varchar , citext , bpchar , macaddr8 , text , money |
Boolean | boolean , bool |
UUID | uuid |
Long | bigint ,int8 ,bigserial ,serial8 |
BigDecimal | numeric ,decimal |
Date | date |
Time | time , time without time zone |
TimeWithTimeZone | timetz , time with time zone |
DateTime | timestamp ,timestamp without time zone |
DateTimeWithTimeZone | timestamptz ,timestamp with time zone |
note
If a column's database type is not available in the above table, GraphQLize assumes String
as the default scalar data type for the corresponding GraphQL field.