■ ■ ■ ■ ■ ■
server/src-lib/Hasura/GraphQL/Schema/Table.hs
| 1 | + | {-# LANGUAGE TemplateHaskellQuotes #-} |
| 2 | + | |
1 | 3 | | -- | Helper functions for generating the schema of database tables |
2 | 4 | | module Hasura.GraphQL.Schema.Table |
3 | 5 | | ( getTableGQLName, |
| skipped 91 lines |
95 | 97 | | Just $ |
96 | 98 | | G.Description $ |
97 | 99 | | "select columns of table " <>> tableInfoName tableInfo |
98 | | - | pure $ |
99 | | - | P.enum enumName description |
100 | | - | <$> nonEmpty |
101 | | - | [ ( define $ ciName column, |
102 | | - | ciColumn column |
103 | | - | ) |
104 | | - | | column <- columns |
105 | | - | ] |
| 100 | + | -- We noticed many 'Definition's allocated, from 'define' below, so memoize |
| 101 | + | -- to gain more sharing and lower memory residency. |
| 102 | + | case nonEmpty $ map (define . ciName &&& ciColumn) columns of |
| 103 | + | Nothing -> pure Nothing |
| 104 | + | Just columnDefinitions -> |
| 105 | + | Just |
| 106 | + | <$> ( P.memoizeOn 'tableSelectColumnsEnum (enumName, description, columns) $ |
| 107 | + | pure $ |
| 108 | + | P.enum enumName description columnDefinitions |
| 109 | + | ) |
106 | 110 | | where |
107 | 111 | | define name = |
108 | 112 | | P.Definition name (Just $ G.Description "column name") Nothing [] P.EnumValueInfo |
| skipped 126 lines |