Author:
Fluent Commerce
Changed on:
12 Feb 2024
If there is a sub-section in the query, then we need to rename the field from the subquery.
Here is an example of renaming the retailer ref and id field:
1{
2 waves19:waves{
3 edges{
4 node{
5 id
6 ref
7 name
8 retailer{
9 ref
10 id
11 }
12 status
13 type
14 createdOn
15 updatedOn
16 }
17 }
18 }
19}
Language: json
Name: Query subsection before the modification
Description:
[Warning: empty required content area]You can change the value from
1retailer{
2 ref
3 id
4 }
Language: graphqlschema
Name: snippet “before"
Description:
[Warning: empty required content area]to
1retailer.ref
2retailer.id
Language: graphqlschema
Name: snippet “after"
Description:
[Warning: empty required content area]when you paste the code into the
`#4 query field`
1import json
2import csv
3import requests
4from graphqlclient import GraphQLClient
5from http.client import IncompleteRead
6from datetime import datetime
7
8########################################## start of configuration ######################################################
9
10#1 App Name: oms or store
11appName ="oms"
12
13#2 GraphQL:
14GraphqlQuery = """
15{
16 waves19:waves{
17 edges{
18 node{
19 id
20 ref
21 name
22 status
23 type
24 createdOn
25 updatedOn
26 }
27 }
28 }
29}
30"""
31
32#3 entity Name / path Name
33entityName = "waves19"
34dataSource = "waves19"
35
36#4 query field
37fieldList = """
38 id
39 ref
40 name
41 status
42 type
43 createdOn
44 updatedOn
45
46"""
47
48#5 (optional) Path name on the navigation bar. if empty then it will use the entityName
49path_nav_name = "my waves19"
50
51#6 (optional) Path name on the navigation bar. if empty then it will use the entityName
52listPage_nav_name = "my waves19"
53
54#7 (optional) Path name on the List Title. if empty then it will use the entityName
55listPageTitle_nav_name = "my waves19 list"
56
57
58########################################## End of configuration ########################################################
59
60path_nav = "fc."+entityName+".nav"
61if len(path_nav_name) < 1:
62 path_nav_name = entityName
63
64listPage_nav = "fc."+entityName+".index.nav"
65if len(listPage_nav_name) < 1:
66 listPage_nav_name = entityName
67
68listPageTitle_nav = "fc."+entityName+".index.title"
69if len(listPageTitle_nav_name) < 1:
70 listPageTitle_nav_name = entityName
71
72aList = [x.strip() for x in fieldList.split("\n")]
73#print(aList)
74#print(aList[1])
75
76GraphqlQuery = GraphqlQuery.replace("\n","")
77#print(GraphqlQuery)
78
79
80languageRow = []
81languageRow.append('"'+path_nav+'": "'+path_nav_name+'",')
82languageRow.append('"'+listPage_nav+'": "'+listPage_nav_name+'",')
83languageRow.append('"'+listPageTitle_nav+'": "'+listPageTitle_nav_name+'",')
84
85settingName = "fc.mystique.manifest.oms.fragment."+entityName
86
87
88
89# Output the segment for webapp Manifest Document:
90
91print("################################# Output the segment for webapp Manifest Document: #############################")
92print(',')
93print(' {')
94print(' "type": "reference",')
95print(' "settingName": "'+settingName+'"')
96print(' }')
97print("################################# copy above Output and put into fc.mystique.manifest.",appName,"###############")
98
99print("")
100print("")
101
102
103print("################################# Craete a new setting for the new list page:",entityName ," ###################")
104print("### setting name:",settingName )
105print("### Context: ACCOUNT:" )
106print("### Context ID: 0" )
107print("### Value Type: JSON" )
108print("### JSON Value:" )
109print("" )
110
111
112print('{')
113print(' "manifestVersion": "2.0",')
114print(' "routes": [')
115print(' {')
116print(' "type": "section",')
117print(' "nav": {')
118print(' "label": "i18n:'+path_nav+'",')
119print(' "icon": "view_list"')
120print(' },')
121print(' "pages": [')
122print(' {')
123print(' "path": "'+entityName+'",')
124print(' "type": "page",')
125print(' "component": "fc.page",')
126print(' "data": {')
127print(' "query": "query '+GraphqlQuery+'",')
128print(' "variables": {')
129#print(' "$qfirst": 100')
130print(' }')
131print(' },')
132print(' "nav": {')
133print(' "label": "i18n:'+listPage_nav+'",')
134print(' "icon": "MdTab"')
135print(' },')
136print(' "props": {')
137print(' "title": "'+listPageTitle_nav_name+'"')
138print(' },')
139print(' "descendants": [')
140print(' {')
141print(' "component": "fc.list",')
142print(' "props": {')
143print(' "dataSource": "'+dataSource+'",')
144print(' "filter": {')
145print(' "enabled": true,')
146print(' "exclude": [')
147print(' "workflowRef",')
148print(' "workflowVersion"')
149print(' ]')
150print(' },')
151print(' "attributes": [')
152i = 0
153while i < len(aList):
154 #print("a:", i, ":", aList[i])
155 if len(aList[i]) > 0:
156 if i > 1:
157 print(",")
158 print(' {')
159 tlabel = 'fc.'+entityName+'.index.list.column.'+aList[i]+'.heading'
160 print(' "label": "i18n:'+tlabel+'",')
161 print(' "template": "{{node.'+aList[i]+'}}"')
162 print(' }')
163 languageRow.append('"'+tlabel+'": "'+aList[i]+'",')
164 i+=1
165print(' ]')
166print(' }')
167print(' }')
168print(' ]')
169print(' }')
170print(' ]')
171print(' }')
172print(' ]')
173print('}')
174print("################################################################################################################")
175
176
177
178print("###################### Output the segment for Language output: LANGUAGE_EN-AU #############################")
179
180i = 0
181while i < len(languageRow):
182 print(languageRow[i])
183 i+=1
184
185print("################################################################################################################")
186
Language: python
Name: Full code
Description:
[Warning: empty required content area]The Code can be enhanced further to directly create / update settings.
Copyright © 2024 Fluent Retail Pty Ltd (trading as Fluent Commerce). All rights reserved. No materials on this docs.fluentcommerce.com site may be used in any way and/or for any purpose without prior written authorisation from Fluent Commerce. Current customers and partners shall use these materials strictly in accordance with the terms and conditions of their written agreements with Fluent Commerce or its affiliates.