nextjs-wordpress-starter icon indicating copy to clipboard operation
nextjs-wordpress-starter copied to clipboard

CPT: Expected type IvIdType, found SLUG

Open sloyer opened this issue 1 year ago • 0 comments

``Hey there,

Running into an issue retrieving posts by an ID.

I can view my posts on /ivs and see all them there, but clicking into them results too "Expected type IvIdType, found SLUG"

Has anyone ran into a similar issues, this is my first time coming around to it.

queryIvById.js file

`import authorPostFields from '@/lib/wordpress/_query-partials/authorPostFields'
import defaultPageData from '@/lib/wordpress/_query-partials/defaultPageData'
import featuredImagePostFields from '@/lib/wordpress/_query-partials/featuredImagePostFields'
import globalPostFields from '@/lib/wordpress/_query-partials/globalPostFields'
import seoPostFields from '@/lib/wordpress/_query-partials/seoPostFields'
import { gql } from '@apollo/client'

// Fragment: retrieve single team member fields.
const singleIvFragment = gql`
  fragment SingleIvFields on Iv {
    ${globalPostFields}
    blocksJSON
    excerpt
    ${seoPostFields}
    ${authorPostFields}
    ${featuredImagePostFields}
  }
`

// Query: retrieve team member by specified identifier.
const queryIvById = gql`
  query GET_IV_BY_ID(
    $id: ID!
    $idType: IvIdType = SLUG
    $imageSize: MediaItemSizeEnum = LARGE
  ) {
    ${defaultPageData}
    iv(id: $id, idType: $idType) {
      ...SingleIvFields
    }
  }
  ${singleIvFragment}



`

export default queryIvById
`
````import authorPostFields from '@/lib/wordpress/_query-partials/authorPostFields'
import defaultPageData from '@/lib/wordpress/_query-partials/defaultPageData'
import featuredImagePostFields from '@/lib/wordpress/_query-partials/featuredImagePostFields'
import globalPostFields from '@/lib/wordpress/_query-partials/globalPostFields'
import seoPostFields from '@/lib/wordpress/_query-partials/seoPostFields'
import { gql } from '@apollo/client'

// Fragment: retrieve single team member fields.
const singleIvFragment = gql`
  fragment SingleIvFields on Iv {
    ${globalPostFields}
    blocksJSON
    excerpt
    ${seoPostFields}
    ${authorPostFields}
    ${featuredImagePostFields}
  }
`

// Query: retrieve team member by specified identifier.
const queryIvById = gql`
  query GET_IV_BY_ID(
    $id: ID!
    $idType: IvIdType = SLUG
    $imageSize: MediaItemSizeEnum = LARGE
  ) {
    ${defaultPageData}
    iv(id: $id, idType: $idType) {
      ...SingleIvFields
    }
  }
  ${singleIvFragment}



`

export default queryIvById
`

`import authorPostFields from '@/lib/wordpress/_query-partials/authorPostFields'
import defaultPageData from '@/lib/wordpress/_query-partials/defaultPageData'
import featuredImagePostFields from '@/lib/wordpress/_query-partials/featuredImagePostFields'
import globalPostFields from '@/lib/wordpress/_query-partials/globalPostFields'
import seoPostFields from '@/lib/wordpress/_query-partials/seoPostFields'
import { gql } from '@apollo/client'

// Fragment: retrieve single team member fields.
const singleIvFragment = gql`
  fragment SingleIvFields on Iv {
    ${globalPostFields}
    blocksJSON
    excerpt
    ${seoPostFields}
    ${authorPostFields}
    ${featuredImagePostFields}
  }
`

// Query: retrieve team member by specified identifier.
const queryIvById = gql`
  query GET_IV_BY_ID(
    $id: ID!
    $idType: IvIdType = SLUG
    $imageSize: MediaItemSizeEnum = LARGE
  ) {
    ${defaultPageData}
    iv(id: $id, idType: $idType) {
      ...SingleIvFields
    }
  }
  ${singleIvFragment}



`

export default queryIvById
`

sloyer avatar Jul 20 '22 23:07 sloyer