I am trying to make test on Karate by using .graphql file and passing variables. On my graphql schema, I am trying to reuse fragment from another .graphql file. I tried following the explanation on https://www.apollographql.com/docs/react/advanced/fragments#webpack-importing-fragments but when I run the Karate test with #import statement on .graphql file, the test failed saying the fragment is unknown.
FindProfile.feature
@smoke
Feature: Test GraphQL FindTrendingProfiles
Background:
* url 'https://192.168.0.0.1'
Scenario: FindTrendingProfiles Request
Given def query = read('FindProfile.graphql')
And def variables = { cursor: "1", cursorType: PAGE, size: 2 }
And request { query: '#(query)', variables: '#(variables)' }
When method post
Then status 200
FindProfile.graphql
#import "./Media.graphql"
query FindProfile($cursor: String, $cursorType: CursorType!, $size: Int!) {
FindProfile(cursor: $cursor, cursorType: $cursorType, size: $size) {
edges{
id
profilePictureMedia{
...Media
}
}
}
}
Media.graphql
fragment Media on Media {
id
title
description
}
I expect that I can reuse the fragment from another .graphql file, but the actual I cannot do that. Any help is greatly appreciated. Thank you.