IHP Api Reference
Safe HaskellNone

IHP.GraphQL.Compiler

Synopsis

Documentation

data SqlQuery Source #

Constructors

SqlQuery 

Fields

data QueryPart Source #

Constructors

QueryPart 

Fields

Instances

Instances details
IsString QueryPart Source # 
Instance details

Defined in IHP.GraphQL.Compiler

Semigroup QueryPart Source # 
Instance details

Defined in IHP.GraphQL.Compiler

Monoid QueryPart Source # 
Instance details

Defined in IHP.GraphQL.Compiler

compileDocument :: Variables -> Document -> [(Query, [Action])] Source #

compileSelectionToInsertStatement :: [Argument] -> Selection -> Text -> QueryPart Source #

Turns a create.. mutation into a INSERT SQL query

Input GraphQL document:

mutation CreateProject($$project: Project) {
    createProject(project: $$project) {
        id title
    }
}

Input Arguments:

project =
    { title: "Hello World"
    , userId: "dc984c2f-d91c-4143-9091-400ad2333f83"
    }

Output SQL Query:

INSERT INTO projects (user_id, title)
    VALUES ('dc984c2f-d91c-4143-9091-400ad2333f83', 'Hello World')
    RETURNING json_build_object('id', projects.id, 'title', projects.title)

compileSelectionToUpdateStatement :: [Argument] -> Selection -> Text -> QueryPart Source #

Turns a update.. mutation into a UPDATE SQL query

Input GraphQL document:

mutation UpdateProject($projectId: ProjectId, patch: $patch) {
    updateProject(id: $projectId, patch: $patch) {
        id title
    }
}

Input Arguments:

projectId = "df1f54d5-ced6-4f65-8aea-fcd5ea6b9df1"
project =
    { title: "Hello World"
    , userId: "dc984c2f-d91c-4143-9091-400ad2333f83"
    }

Output SQL Query:

UPDATE projects
    SET title = 'Hello World', user_id = 'dc984c2f-d91c-4143-9091-400ad2333f83'
    WHERE id = 'df1f54d5-ced6-4f65-8aea-fcd5ea6b9df1'
    RETURNING json_build_object('id', projects.id, 'title', projects.title)

compileSelectionToDeleteStatement :: [Argument] -> Selection -> Text -> QueryPart Source #

Turns a delete.. mutation into a DELETE SQL query

Input GraphQL document:

mutation DeleteProject($$projectId: ProjectId) {
    deleteProject(id: $$project) {
        id title
    }
}

Input Arguments:

projectId = "dc984c2f-d91c-4143-9091-400ad2333f83"

Output SQL Query:

DELETE FROM projects
    WHERE project_id = 'dc984c2f-d91c-4143-9091-400ad2333f83'
    RETURNING json_build_object('id', projects.id, 'title', projects.title)

valueToSQL :: Value -> Action Source #

unpackQueryPart :: QueryPart -> (Query, [Action]) Source #