Hi Everyone, is there a dedicated channel for the ...
# help
v
Hi Everyone, is there a dedicated channel for the Graphql extension ? I'm working on an app with fairly complex queries and for the life of me I can't get it to match anything.
l
No dedicated channel. Can you post more about what you are doing
v
Hi @Lee Turner So I'm working on an application for which the entire BE is graphql. The FE is built with Apollo and it has fairly large queries with the projected responses being built out of multiple fragments. I have requests that look something like this. I have tried multiple ways of defining the argument string that I pass to the
Copy code
GraphqlBodyMatcher.parameters
method but nothing resulted in a match when doing the actual request from the FE
Copy code
{
  "operationName": "authenticationData",
  "variables": {},
  "query": "fragment CreatorFields on User {
    id
    firstname
    surname
    email
    __typename
  }

  fragment ProductLiteFields on Product {
    id
    name
    numberingFormat
    soloModeSupported
    allowMultipleInstances
    status
    __typename
  }

  fragment ContractSectionFields on ContractSection {
    id
    number
    description
    completionDate
    status
    dateCreated
    dateModified
    creatorId
    creator {
      ...CreatorFields
      __typename
    }
    __typename
  }

  fragment ContractKeyDateFields on ContractKeyDate {
    id
    number
    conditionToBeMet
    keyDate
    status
    dateCreated
    dateModified
    creatorId
    creator {
      ...CreatorFields
      __typename
    }
    __typename
  }

  fragment ContractLiteFields on Contract {
    id
    name
    friendlyName
    number
    valueCurrency
    value
    startDate
    endDate
    contractTypeId
    projectId
    country
    province
    timeZone
    coordinatesLatitude
    coordinatesLongitude
    sections {
      ...ContractSectionFields
      __typename
    }
    keyDates {
      ...ContractKeyDateFields
      __typename
    }
    status
    dateCreated
    creatorId
    creator {
      ...CreatorFields
      __typename
    }
    project {
      id
      name
      friendlyName
      status
      __typename
    }
    contractType {
      id
      description
      subType
      version
      status
      __typename
    }
    __typename
  }

  fragment ProductInstanceLiteFields on ProductInstance {
    id
    description
    numberingFormat
    soloModeSupported
    contractId
    productId
    productSchemaId
    statusCollectionId
    status
    dateCreated
    creatorId
    creator {
      ...CreatorFields
      __typename
    }
    contract {
      ...ContractLiteFields
      __typename
    }
    product {
      ...ProductLiteFields
      __typename
    }
    statusCollection {
      id
      name
      isDefault
      status
      __typename
    }
    __typename
  }

  fragment AddressFields on Address {
    line1
    line2
    city
    provinceState
    country
    code
    __typename
  }

  fragment CompanyLiteFields on Company {
    id
    type
    registeredName
    tradingName
    registrationNumber
    logo
    vatRegistrationNumber
    physicalAddress {
      ...AddressFields
      __typename
    }
    postalAddress {
      ...AddressFields
      __typename
    }
    status
    creatorId
    dateCreated
    creator {
      ...CreatorFields
      __typename
    }
    __typename
  }

  fragment UserFields on User {
    id
    firstname
    surname
    jobTitle
    country
    mobileNumber
    alternateNumber
    dateOfBirth
    profilePicture
    email
    companyId
    company {
      ...CompanyLiteFields
      __typename
    }
    registered
    status
    lastActive
    dateInvited
    registeredDate
    invitedBy {
      ...CreatorFields
      __typename
    }
    roles {
      items {
        userId
        productInstanceId
        productInstance {
          ...ProductInstanceLiteFields
          __typename
        }
        productRoleId
        status
        dateCreated
        creatorId
        creator {
          ...CreatorFields
          __typename
        }
        user {
          ...CreatorFields
          __typename
        }
        productRole {
          id
          name
          productId
          actionIds
          isInternal
          status
          dateCreated
          creatorId
          creator {
            ...CreatorFields
            __typename
          }
          actions {
            items {
              id
              name
              isInternal
              status
              dateCreated
              creatorId
              creator {
                ...CreatorFields
                __typename
              }
              __typename
            }
            __typename
          }
          __typename
        }
        __typename
      }
      __typename
    }
    __typename
  }

  query authenticationData {
    authenticationData {
      user {
        ...UserFields
        __typename
      }
      isAdmin
      intercomIdentityHash
      __typename
    }
  }"
}
Do I need to pass the operation name and an empty map vor variables as well ?
l
Hi, sorry but I haven't used the OSS graphql extension before so will need some time to test this up and test (I have used the WireMock Cloud graphql integration more than the OSS version) Have you been able to get a simpler setup working that doesn't require such big payloads? I was also wondering if it would be worth using a graphql client to send a query to WireMock instead of your frontend to see if that would help get things setup?
v
I've tried doing some simple requests using RestAssured and those were matching. I've also tried mocking a smaller request from the FE with no results The smallest request I have from the FE is this one
Copy code
{
    "operationName":"unreadNotifications",
    "variables":{},
    "query":"query unreadNotifications {  
        unreadNotifications
        }"
}
ok I figured it out... I forgot to enable stub cors 🤦‍♂️
l
Ah, great find. Well done. Thank you for letting us know