- 
                Notifications
    
You must be signed in to change notification settings  - Fork 17
 
Functions:parseToGqlFragment
        Justin van der Velden edited this page May 1, 2023 
        ·
        9 revisions
      
    The parseToGqlFragment returns a Gql fragment based on the PropertyMap option which can be used to query a record. The id for the record is also returned in the fragment, so you won't have to specify the id in the query. This function expects the value of the PropertyMap option and a model name and will return an object containing the information for the fragment. The returned fragment can then be used to create a query to fetch all the fields that were passed in the PropertyMap.
Example:
// PropertyMap option
const propertyMap = [
  {
    key: [
      {
        name: 'firstName',
        kind: 'STRING',
      },
    ],
    value: 'John',
  },
  {
    key: [
      {
        name: 'lastName',
        kind: 'STRING',
      },
    ],
    value: 'Doe',
  },
];
// Model option
const modelName = 'Task'
const { name, gql: fragmentGql } = await parseToGqlFragment({
  propertyMap,
  modelName,
});
const query = `
  ${fragmentGql}
  query($where: ${modelName}FilterInput) {
    ${queryName}(where: $where) {
      ...${name}
    }
  }
`;
await gql(query);- Getting started
 - Page Builder Components
 - Action Functions
 - [deprecated] CustomFunctions