Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wagtail grapple support #66

Open
minusplusminus opened this issue Apr 19, 2022 · 0 comments
Open

wagtail grapple support #66

minusplusminus opened this issue Apr 19, 2022 · 0 comments

Comments

@minusplusminus
Copy link

Hi,

I'm trying to get wagtail-grapple to support your toolkit. See https://wagtail-grapple.readthedocs.io/en/latest/

There are a few issues I have related to generating cache when using the lib.

   const nodeInterface = schema.getType(`PageInterface`)
    const possibleTypes = schema.getPossibleTypes(nodeInterface)

    const gatsbyNodeTypes = possibleTypes.map((type) => {
        let query = `
   query LIST_${pluralize(type.name).toUpperCase()} ($limit: PositiveInt, $offset: PositiveInt) {
 
      pages(limit: $limit, offset: $offset) {
      remoteId: id
        ..._${type.name}Id_
        
      }
    
    }
    fragment _${type.name}Id_ on ${type.name} {
         remoteId: id
        __typename
        id
    }
    `;

This will generate a fragment:

fragment BlogPage on BlogPage {
  remoteId: id
  path
  depth
  numchild
  translationKey
  title
  draftTitle
  slug
  contentType
  live
  hasUnpublishedChanges
  urlPath
  seoTitle
  showInMenus
  searchDescription
  goLiveAt
  expireAt
  expired
  locked
  lockedAt
  firstPublishedAt
  lastPublishedAt
  latestRevisionCreatedAt
  aliasOf {
    ... on Page {
      remoteTypeName: __typename
      remoteId: id
      remoteId: id
    }
  }
  author
  date
  body {
    ... on StreamFieldBlock {
      id
      blockType
      field
      rawValue
      value
    }
    ... on CharBlock {
      id
      blockType
      field
      rawValue
      value
    }
    ... on TextBlock {
      id
      blockType
      field
      rawValue
      value
    }
    ... on EmailBlock {
      id
      blockType
      field
      rawValue
      value
    }
    ... on IntegerBlock {
      id
      blockType
      field
      rawValue
      value
    }
    ... on FloatBlock {
      id
      blockType
      field
      rawValue
      value
    }
    ... on DecimalBlock {
      id
      blockType
      field
      rawValue
      value
    }
    ... on RegexBlock {
      id
      blockType
      field
      rawValue
      value
    }
    ... on URLBlock {
      id
      blockType
      field
      rawValue
      value
    }
    ... on BooleanBlock {
      id
      blockType
      field
      rawValue
      value
    }
    ... on DateBlock {
      id
      blockType
      field
      rawValue
      value
    }
    ... on TimeBlock {
      id
      blockType
      field
      rawValue
      value
    }
    ... on DateTimeBlock {
      id
      blockType
      field
      rawValue
      value
    }
    ... on RichTextBlock {
      id
      blockType
      field
      rawValue
      value
    }
    ... on RawHTMLBlock {
      id
      blockType
      field
      rawValue
      value
    }
    ... on BlockQuoteBlock {
      id
      blockType
      field
      rawValue
      value
    }
    ... on ChoiceBlock {
      id
      blockType
      field
      rawValue
      value
      choices {
        ... on ChoiceOption {
          key
          value
        }
      }
    }
    ... on StreamBlock {
      id
      blockType
      field
      rawValue
      blocks {
        remoteTypeName: __typename
      }
    }
    ... on StructBlock {
      id
      blockType
      field
      rawValue
      blocks {
        remoteTypeName: __typename
      }
    }
    ... on StaticBlock {
      id
      blockType
      field
      rawValue
      value
    }
    ... on ListBlock {
      id
      blockType
      field
      rawValue
      items {
        remoteTypeName: __typename
      }
    }
    ... on EmbedBlock {
      id
      blockType
      field
      rawValue
      value
      url
      embed
      rawEmbed
    }
    ... on PageChooserBlock {
      id
      blockType
      field
      rawValue
      page {
        ... on PageInterface {
          remoteTypeName: __typename
          remoteId: id
        }
      }
    }
    ... on DocumentChooserBlock {
      id
      blockType
      field
      rawValue
      document {
        ... on DocumentObjectType {
          id
          collection {
            ... on CollectionObjectType {
              id
              path
              depth
              numchild
              name
              descendants {
                remoteTypeName: __typename
              }
              ancestors {
                remoteTypeName: __typename
              }
            }
          }
          title
          file
          createdAt
          fileSize
          fileHash
          url
          tags {
            ... on TagObjectType {
              id
              name
            }
          }
        }
      }
    }
    ... on ImageChooserBlock {
      id
      blockType
      field
      rawValue
      image {
        ... on CustomImage {
          id
          collection {
            ... on CollectionObjectType {
              id
              path
              depth
              numchild
              name
              descendants {
                remoteTypeName: __typename
              }
              ancestors {
                remoteTypeName: __typename
              }
            }
          }
          title
          file
          width
          height
          createdAt
          focalPointX
          focalPointY
          focalPointWidth
          focalPointHeight
          fileSize
          fileHash
          src
          url
          aspectRatio
          sizes
          tags {
            ... on TagObjectType {
              id
              name
            }
          }
          rendition {
            ... on CustomImageRendition {
              id
              file
              width
              height
              image {
                remoteTypeName: __typename
              }
              title
              createdAt
              focalPointX
              focalPointY
              focalPointWidth
              focalPointHeight
              fileSize
              fileHash
              src
              url
              aspectRatio
              sizes
              collection {
                ... on CollectionObjectType {
                  id
                  path
                  depth
                  numchild
                  name
                  descendants {
                    remoteTypeName: __typename
                  }
                  ancestors {
                    remoteTypeName: __typename
                  }
                }
              }
              tags {
                ... on TagObjectType {
                  id
                  name
                }
              }
              rendition {
                remoteTypeName: __typename
              }
              srcSet
              customRenditionProperty
            }
          }
          srcSet
          image640
          image800
          image1024
        }
      }
    }
    ... on SnippetChooserBlock {
      id
      blockType
      field
      rawValue
      snippet
    }
  }
  pageType
  url
  remoteParent: parent {
    ... on PageInterface {
      remoteTypeName: __typename
      remoteId: id
    }
  }
  remoteChildren: children {
    ... on PageInterface {
      remoteTypeName: __typename
      remoteId: id
    }
  }
  siblings {
    ... on PageInterface {
      remoteTypeName: __typename
      remoteId: id
    }
  }
  nextSiblings {
    ... on PageInterface {
      remoteTypeName: __typename
      remoteId: id
    }
  }
  previousSiblings {
    ... on PageInterface {
      remoteTypeName: __typename
      remoteId: id
    }
  }
  descendants {
    ... on PageInterface {
      remoteTypeName: __typename
      remoteId: id
    }
  }
  ancestors {
    ... on PageInterface {
      remoteTypeName: __typename
      remoteId: id
    }
  }
}

generates the needed pages. But I have a few things that don't work correctly:

The lib adds a value key, which conflicts because the interface classes overlap that are generated.

 Error: Failed to execute query LIST_BLOGPAGES.
  Errors:
  Fields "value" conflict because they return conflicting types String! and Int!. Use different aliases on the fields to fetch both if this was intentional.
  Fields "value" conflict because they return conflicting types String! and Float!. Use different aliases on the fields to fetch both if this was intentional.
  Fields "value" conflict because they return conflicting types String! and Float!. Use different aliases on the fields to fetch both if this was intentional.

StreamBlocks have multiple blocks

 ... on StreamBlock {
      id
      blockType
      field
      rawValue
      blocks {
        remoteTypeName: __typename

      }
    }

StreamBlock.blocks has multiple interfaces, but not recognize.

Currently I use regex to fix the missing keys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant