Documentation ¶
Index ¶
- type AssetNode
- type GraphCMS
- func (g *GraphCMS) Backup()
- func (g *GraphCMS) CallGraphAPI(requestQuery string, requestVars string) (GraphResponse, error)
- func (g *GraphCMS) DownloadAssets(data map[string]interface{})
- func (g *GraphCMS) DownloadContent()
- func (g *GraphCMS) DownloadEnumerations() error
- func (g *GraphCMS) DownloadModels() error
- func (g *GraphCMS) DownloadSchemas() error
- func (g *GraphCMS) GetAllEnumerations() []interface{}
- func (g *GraphCMS) GetAllNodesByType(name string) map[string]interface{}
- func (g *GraphCMS) GetEnumeration(name string) interface{}
- func (g *GraphCMS) GetEnumerations() map[string]interface{}
- func (g *GraphCMS) GetNodeFields(name string) map[string]interface{}
- func (g *GraphCMS) GetNodeTypes() []string
- func (g *GraphCMS) GetNodes() map[string]interface{}
- func (g *GraphCMS) GetSchema(name string) (interface{}, error)
- func (g *GraphCMS) GetSchemaQuery(name string) (string, string)
- func (g *GraphCMS) GetSchemas() map[string]interface{}
- func (g *GraphCMS) Init(url interface{}, key interface{}, stage interface{}, path interface{})
- func (g *GraphCMS) IsNodeType(name string) bool
- func (g *GraphCMS) IsSpecialCase(name string) bool
- func (g *GraphCMS) Pluralize(name string) string
- func (g *GraphCMS) RenderJson(data map[string]interface{}) string
- func (g *GraphCMS) RenderJsonPretty(data map[string]interface{}) string
- func (g *GraphCMS) RenderTemplate(query string, template string, outputFilename string)
- func (g *GraphCMS) SetFlags(debug bool, verbose bool)
- func (g *GraphCMS) WriteFileJSON(data map[string]interface{}, folder string, filename string)
- type GraphResponse
- type NodeFields
- type NodeSubfield
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetNode ¶
type AssetNode struct { TypeName string `json:"__typename"` ID string `json:"id"` Handle string `json:"handle"` URL string `json:"url"` }
AssetNode simple content struct
type GraphCMS ¶
type GraphCMS struct { NodeTypes []string SpecialCases map[string]string Debug bool Verbose bool Exceptions map[string]string RenderData GraphResponse // contains filtered or unexported fields }
GraphCMS struct
func (*GraphCMS) CallGraphAPI ¶
func (g *GraphCMS) CallGraphAPI(requestQuery string, requestVars string) (GraphResponse, error)
CallGraphAPI to make a GraphQL API call with requestQuery & requestVars
func (*GraphCMS) DownloadAssets ¶
DownloadAssets loop through nodes, look for assets and download
func (*GraphCMS) DownloadContent ¶
func (g *GraphCMS) DownloadContent()
DownloadContent from GraphCMS
func (*GraphCMS) DownloadEnumerations ¶
DownloadEnumerations to a file
func (*GraphCMS) DownloadModels ¶
DownloadModels to a file
func (*GraphCMS) DownloadSchemas ¶
DownloadSchemas to a file. Download both models and enumerations.
func (*GraphCMS) GetAllEnumerations ¶
func (g *GraphCMS) GetAllEnumerations() []interface{}
GetAllEnumerations from the API using introspection This returns numerous ENUMS including any system enumerations
func (*GraphCMS) GetAllNodesByType ¶
GetAllNodesByType will give you all nodes for a given node type. GraphQL does not let you select * like SQL, so we need to take the fields grabbed by introspection and build a graphql query to pull all fields for a given node type (schema model)
func (*GraphCMS) GetEnumeration ¶
GetEnumeration get a single enumeration by name from the API using introspection
func (*GraphCMS) GetEnumerations ¶
GetEnumerations from the CMS based on enumerations defined in your config
func (*GraphCMS) GetNodeFields ¶
GetNodeFields returns a single schema as json
func (*GraphCMS) GetNodeTypes ¶
GetNodeTypes will get node types from the API using introspection
func (*GraphCMS) GetSchemaQuery ¶
GetSchemaQuery returns a GraphQL query
func (*GraphCMS) GetSchemas ¶
GetSchemas retrives the schema and returns json
func (*GraphCMS) Init ¶
func (g *GraphCMS) Init(url interface{}, key interface{}, stage interface{}, path interface{})
Init initialize config
func (*GraphCMS) IsNodeType ¶
IsNodeType check to see if name is listed as one of the node types
func (*GraphCMS) IsSpecialCase ¶
IsSpecialCase field type
func (*GraphCMS) Pluralize ¶
Pluralize will transform the schema model (node type) name to plural Took the 80/20 rule here and tried to capture the bulk of the cases with minimal logic English can be an ugly language, see rules at https://www.grammarly.com/blog/plural-nouns/
func (*GraphCMS) RenderJson ¶
RenderJson converts the incoming data to a formatted json string
func (*GraphCMS) RenderJsonPretty ¶
RenderJsonPretty converts the incoming data to an indented json string
func (*GraphCMS) RenderTemplate ¶
RenderTemplate with CMS data
type GraphResponse ¶
type GraphResponse struct { Data map[string]interface{} `json:"data"` Errors []struct { Message string `json:message` Locations []interface{} `json:"locations"` } `json:"errors"` }
GraphResponse GraphCMS API response
type NodeFields ¶
type NodeFields struct { Type struct { Name string `json:"name"` Kind string `json:"kind"` Fields []struct { Name string `json:"name"` Description string `json:"description"` Args []struct { Name string `json:"name"` Description string `json:"description"` DefaultValue string `json:"defaultValue"` } `json:"args"` Type struct { Name string `json:"name"` Kind string `json:"kind"` Description string `json:"description"` Fields []NodeSubfield `json:"fields"` PossibleTypes []struct { Name string `json:"name"` Description string `json:"description"` } `json:"possibleTypes"` OfType struct { Name string `json:"name"` Description string `json:"description"` } `json:"ofType"` Interfaces []struct { Name string `json:"name"` Description string `json:"description"` Typename string `json:"__typename"` } `json:"interfaces"` } `json:"type"` } `json:"fields"` } `json:"__type"` }
NodeFields structure
type NodeSubfield ¶
type NodeSubfield struct { Name string `json:"name"` Description string `json:"description"` Args []struct { Name string `json:"name"` Description string `json:"description"` DefaultValue string `json:"defaultValue"` } `json:"args"` Type struct { Fields []struct { Name string `json:"name"` Description string `json:"description"` Args []struct { Name string `json:"name"` Description string `json:"description"` } `json:"args"` } `json:"fields"` } `json:"type"` }
NodeSubfield structure