Safe Haskell | Safe-Inferred |
---|
IHP.GraphQL.Compiler
Synopsis
- data SqlQuery = SqlQuery {}
- data QueryPart = QueryPart {}
- compileDocument :: Variables -> Document -> [(Query, [Action])]
- compileDefinition :: Document -> Definition -> [Argument] -> QueryPart
- compileMutationDefinition :: Definition -> [Argument] -> [QueryPart]
- compileSelection :: Document -> [Argument] -> Selection -> QueryPart
- selectQueryPieces :: Document -> Action -> Selection -> QueryPart
- fieldToJoin :: Document -> Text -> Selection -> QueryPart
- compileMutationSelection :: [Argument] -> Selection -> QueryPart
- compileSelectionToInsertStatement :: [Argument] -> Selection -> Text -> QueryPart
- compileSelectionToUpdateStatement :: [Argument] -> Selection -> Text -> QueryPart
- compileSelectionToDeleteStatement :: [Argument] -> Selection -> Text -> QueryPart
- valueToSQL :: Value -> Action
- resolveVariables :: Value -> [Argument] -> Value
- unionAll :: [QueryPart] -> QueryPart
- commaSep :: [QueryPart] -> QueryPart
- spaceSep :: [QueryPart] -> QueryPart
- unpackQueryPart :: QueryPart -> (Query, [Action])
- withParams :: [Action] -> QueryPart -> QueryPart
Documentation
compileDocument :: Variables -> Document -> [(Query, [Action])] Source #
compileDefinition :: Document -> Definition -> [Argument] -> QueryPart Source #
compileMutationDefinition :: Definition -> [Argument] -> [QueryPart] 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 #
withParams :: [Action] -> QueryPart -> QueryPart Source #