Creating Mystique Manifest list page by using graphQL query with Pycharm
How-to Guide
Author:
Fluent Commerce
Changed on:
12 Feb 2024
Key Points
This tool is a quick easy way to generate manifest List Page by just providing a GQL query (with edges/node)
Steps
Relevant case scenario:
The code will work on the GQL with edges/node.
Modify the query
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:You can change the value from to when you paste the code into the `#4 query field`The Code can be enhanced further to directly create / update settings.
Fluent Commerce
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}
1retailer{
2 ref
3 id
4 }
1retailer.ref
2retailer.id
1import json
2import csv
3import requests
4from graphqlclient import GraphQLClient
5from http.client import IncompleteRead
6from datetime import datetime
78########################################## start of configuration ######################################################910#1 App Name: oms or store11appName ="oms"1213#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"""3132#3 entity Name / path Name33entityName ="waves19"34dataSource ="waves19"3536#4 query field37fieldList ="""
38 id
39 ref
40 name
41 status
42 type
43 createdOn
44 updatedOn
4546"""4748#5 (optional) Path name on the navigation bar. if empty then it will use the entityName49path_nav_name ="my waves19"5051#6 (optional) Path name on the navigation bar. if empty then it will use the entityName52listPage_nav_name ="my waves19"5354#7 (optional) Path name on the List Title. if empty then it will use the entityName55listPageTitle_nav_name ="my waves19 list"565758########################################## End of configuration ########################################################5960path_nav ="fc."+entityName+".nav"61iflen(path_nav_name)<1:62 path_nav_name = entityName
6364listPage_nav ="fc."+entityName+".index.nav"65iflen(listPage_nav_name)<1:66 listPage_nav_name = entityName
6768listPageTitle_nav ="fc."+entityName+".index.title"69iflen(listPageTitle_nav_name)<1:70 listPageTitle_nav_name = entityName
7172aList =[x.strip()for x in fieldList.split("\n")]73#print(aList)74#print(aList[1])7576GraphqlQuery = GraphqlQuery.replace("\n","")77#print(GraphqlQuery)787980languageRow =[]81languageRow.append('"'+path_nav+'": "'+path_nav_name+'",')82languageRow.append('"'+listPage_nav+'": "'+listPage_nav_name+'",')83languageRow.append('"'+listPageTitle_nav+'": "'+listPageTitle_nav_name+'",')8485settingName ="fc.mystique.manifest.oms.fragment."+entityName
86878889# Output the segment for webapp Manifest Document:9091print("################################# 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,"###############")9899print("")100print("")101102103print("################################# 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("")110111112print('{')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 =0153while i <len(aList):154#print("a:", i, ":", aList[i])155iflen(aList[i])>0:156if i >1:157print(",")158print(' {')159 tlabel ='fc.'+entityName+'.index.list.column.'+aList[i]+'.heading'160print(' "label": "i18n:'+tlabel+'",')161print(' "template": "{{node.'+aList[i]+'}}"')162print(' }')163 languageRow.append('"'+tlabel+'": "'+aList[i]+'",')164 i+=1165print(' ]')166print(' }')167print(' }')168print(' ]')169print(' }')170print(' ]')171print(' }')172print(' ]')173print('}')174print("################################################################################################################")175176177178print("###################### Output the segment for Language output: LANGUAGE_EN-AU #############################")179180i =0181while i <len(languageRow):182print(languageRow[i])183 i+=1184185print("################################################################################################################")186