Skip to content

Other Advanced Features

Aaron Aichlmayr edited this page Apr 11, 2019 · 2 revisions

Adding functions based on GraphQL fields

If you want to add a graphql function which depends on a GraphQL field you only need to add the SqlGraphQLFunc attribute and add the correct properties to the annotation. Those are documented in the code which should be available via Intellisense

Hiding sql fields from the graph

Any time you need to use a SQL field in one of the other annotations (Ex. functions or relationships) you may use the SqlField attribute instead of the SqlGraphQLField annotation. The are functionally equivalent except for the exposure on the graph. Note: A foreign key which is exposed this way will not be mutable.

Cleaning up database data before exposure

You may use the Transform and ReverseTransform properties of the SqlGraphQLField annotation to transform data to / from gnarly database values which you may not want to expose on your api. Ex. If the database uses the string values of "Y" and "N" to represent true and false you can use the transform CAST(CASE WHEN [{0}].[{1}] = 'Y' THEN 1 WHEN [{0}].[{1}] = 'N' THEN 0 ELSE NULL END AS BIT) and the reverse transform CASE WHEN {0} = 1 THEN 'Y' WHEN {0} = 0 THEN 'N' ELSE NULL END the details of how these work are documented in the code which should be available via Intellisense