shame to ask, but we have GraphQL Server on Java (https://github.com/graphql-java/graphql-spring-boot), where we specified type.graphqls scheme for our service.
On client side we have JS code based on Apollo Client library. And it does not need acess to this types file.
But days are come and I need to write some API tests. Most people in our team speaks Python very well, so I decided to make test workbench on python, but I cant't find any library that let me write queries schema-free or import my types.graphqls scheme.
How can I write tests on python for custom GraphQL server thogh?
Thanks!
Asked
Active
Viewed 581 times
0

Timopheym
- 363
- 3
- 15
-
The client (or tests) never actually need access to your schema definition files. All the info can be obtained via introspection, and that is what all libraries normally do. – kaqqao Apr 01 '18 at 00:09
-
introspection? Can you provide some links please? – Timopheym Apr 02 '18 at 15:05
-
Check [here](http://graphql.org/learn/introspection/). The client can get all the info that way. And most libraries provide a way to convert the introspection result into SDL for human readability. – kaqqao Apr 02 '18 at 15:10
1 Answers
1
Finally I found a gist with simple GraphQL client based on requests library:
import requests
def run_query(query, variables):
request = requests.post('https://dev.darkdata.finance:9000/graphql',
json={'query': query, 'variables': variables})
if request.status_code == 200:
return request.json()
else:
raise Exception("Query failed to run by returning code of {}. {}".format(request.status_code, query))
You can use it to test simple queries if you want. Source: https://gist.github.com/gbaman/b3137e18c739e0cf98539bf4ec4366ad

Timopheym
- 363
- 3
- 15