dnadesign / silverstripe-elemental-userforms

Adds a new element for usersforms
BSD 3-Clause "New" or "Revised" License
9 stars 16 forks source link

Graphlq 4 support #76

Closed palomamtnez closed 1 year ago

palomamtnez commented 1 year ago

Im a bit new to Silverstripe, so I was just wondering if there are any examples of how to use this library on my Silverstripe 5 headless site via Graphql.

At the moment, my _graphql/models.yml file looks like this:

Page:
  fields:
    "*": true
  operations:
    read: true
App\HomePage:
  fields:
    "*": true
  operations:
    read: true

SilverStripe\CMS\Model\SiteTree:
  fields:
    "*": true
    bannerLinkImageURL:
      type: String
      property: resolveBannerLinkImageURL
    bannerLink:
        type: String
        property: resolveBannerLink
    children:
      type: "[SiteTreeInterface]"
      property: Children
  operations:
    read: true

DNADesign\Elemental\Models\ElementalArea:
  fields:
    "*": true
  operations:
    readOne: true
DNADesign\Elemental\Models\BaseElement:
  fields: '*'
  operations:
    read: true
DNADesign\Elemental\Models\ElementContent:
  fields: '*'
  operations:
    read: true

And my query looks like this:

query pages {
  readHomePages(filter: { id: { eq: "1" } }, limit: 1) {
    nodes {
      id
      title
      elementalArea {
        elements {
          nodes {
            ... on ElementContent {
              id
              html
              title
            }
            ... on BaseElement {
              __typename
              title
            }
          }
        }
      }
    }
  }
}

and the results look like this:

{
  "data": {
    "readHomePages": {
      "nodes": [
        {
          "id": "1",
          "title": "Homeaa 1",
          "elementalArea": {
            "elements": {
              "nodes": [
                {
                  "__typename": "BaseElement",
                  "title": "test form" <--- This is the form I have created via the admin panel, need to access to the fields, settings, etc.
                },
                {
                  "__typename": "ElementContent",
                  "id": "1",
                  "html": "<p>testing!&nbsp;</p>",
                  "title": "test111"
                }
              ]
            }
          }
        }
      ]
    }
  }
}

Thanks

GuySartorelli commented 1 year ago

Hi @palomamtnez Thank you for your interest and welcome aboard the Silverstripe CMS train. We don't offer support through github issues. Please ask your question on the forum, slack, or stackoverflow.