【发布时间】:2019-10-09 22:09:32
【问题描述】:
我正在尝试使用 .graphql 文件并传递变量来测试空手道。在我的 graphql 模式中,我试图重用另一个 .graphql 文件中的片段。我尝试按照https://www.apollographql.com/docs/react/advanced/fragments#webpack-importing-fragments 上的说明进行操作,但是当我在 .graphql 文件上使用 #import 语句运行空手道测试时,测试失败,提示片段未知。
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
}
我希望我可以重用另一个 .graphql 文件中的片段,但实际上我不能这样做。任何帮助是极大的赞赏。谢谢。
【问题讨论】: