Skip to content

Commit 631f995

Browse files
committed
Added definition and usage example of graphql method
1 parent 31be48f commit 631f995

27 files changed

+1470
-0
lines changed

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,37 @@ configuration.api_key['Referer'] = 'YOUR_API_KEY'
103103
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
104104
# configuration.api_key_prefix['Referer'] = 'Bearer'
105105

106+
# create an instance of the API class
107+
api_instance = swagger_client.DefaultApi(swagger_client.ApiClient(configuration))
108+
body = swagger_client.GraphqlQuery() # GraphqlQuery | GraphQL query (optional)
109+
110+
try:
111+
api_response = api_instance.graphql_post(body=body)
112+
pprint(api_response)
113+
except ApiException as e:
114+
print("Exception when calling DefaultApi->graphql_post: %s\n" % e)
115+
116+
# Configure API key authorization: cookieCSRF
117+
configuration = swagger_client.Configuration()
118+
configuration.api_key['csrftoken'] = 'YOUR_API_KEY'
119+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
120+
# configuration.api_key_prefix['csrftoken'] = 'Bearer'
121+
# Configure API key authorization: cookieSession
122+
configuration = swagger_client.Configuration()
123+
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
124+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
125+
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
126+
# Configure API key authorization: headerCSRF
127+
configuration = swagger_client.Configuration()
128+
configuration.api_key['x-csrftoken'] = 'YOUR_API_KEY'
129+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
130+
# configuration.api_key_prefix['x-csrftoken'] = 'Bearer'
131+
# Configure API key authorization: referer
132+
configuration = swagger_client.Configuration()
133+
configuration.api_key['Referer'] = 'YOUR_API_KEY'
134+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
135+
# configuration.api_key_prefix['Referer'] = 'Bearer'
136+
106137
# create an instance of the API class
107138
api_instance = swagger_client.DefaultApi(swagger_client.ApiClient(configuration))
108139
problem = 'problem_example' # str |
@@ -185,6 +216,7 @@ All URIs are relative to *https://leetcode.com*
185216
Class | Method | HTTP request | Description
186217
------------ | ------------- | ------------- | -------------
187218
*DefaultApi* | [**api_problems_topic_get**](docs/DefaultApi.md#api_problems_topic_get) | **GET** /api/problems/{topic}/ |
219+
*DefaultApi* | [**graphql_post**](docs/DefaultApi.md#graphql_post) | **POST** /graphql |
188220
*DefaultApi* | [**problems_problem_interpret_solution_post**](docs/DefaultApi.md#problems_problem_interpret_solution_post) | **POST** /problems/{problem}/interpret_solution/ |
189221
*DefaultApi* | [**problems_problem_submit_post**](docs/DefaultApi.md#problems_problem_submit_post) | **POST** /problems/{problem}/submit/ |
190222
*DefaultApi* | [**submissions_detail_id_check_get**](docs/DefaultApi.md#submissions_detail_id_check_get) | **GET** /submissions/detail/{id}/check/ |
@@ -193,9 +225,15 @@ Class | Method | HTTP request | Description
193225

194226
- [BaseSubmissionResult](docs/BaseSubmissionResult.md)
195227
- [Difficulty](docs/Difficulty.md)
228+
- [GraphqlQuery](docs/GraphqlQuery.md)
229+
- [GraphqlQueryVariables](docs/GraphqlQueryVariables.md)
230+
- [GraphqlQuestion](docs/GraphqlQuestion.md)
231+
- [GraphqlQuestionDetail](docs/GraphqlQuestionDetail.md)
232+
- [GraphqlResponse](docs/GraphqlResponse.md)
196233
- [Id](docs/Id.md)
197234
- [InlineResponse200](docs/InlineResponse200.md)
198235
- [Interpretation](docs/Interpretation.md)
236+
- [OneOfGraphqlResponseData](docs/OneOfGraphqlResponseData.md)
199237
- [OneOfid](docs/OneOfid.md)
200238
- [OneOfinlineResponse200](docs/OneOfinlineResponse200.md)
201239
- [Problems](docs/Problems.md)

docs/DefaultApi.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ All URIs are relative to *https://leetcode.com*
55
Method | HTTP request | Description
66
------------- | ------------- | -------------
77
[**api_problems_topic_get**](DefaultApi.md#api_problems_topic_get) | **GET** /api/problems/{topic}/ |
8+
[**graphql_post**](DefaultApi.md#graphql_post) | **POST** /graphql |
89
[**problems_problem_interpret_solution_post**](DefaultApi.md#problems_problem_interpret_solution_post) | **POST** /problems/{problem}/interpret_solution/ |
910
[**problems_problem_submit_post**](DefaultApi.md#problems_problem_submit_post) | **POST** /problems/{problem}/submit/ |
1011
[**submissions_detail_id_check_get**](DefaultApi.md#submissions_detail_id_check_get) | **GET** /submissions/detail/{id}/check/ |
@@ -75,6 +76,72 @@ Name | Type | Description | Notes
7576

7677
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
7778

79+
# **graphql_post**
80+
> GraphqlResponse graphql_post(body=body)
81+
82+
83+
84+
### Example
85+
```python
86+
from __future__ import print_function
87+
import time
88+
import swagger_client
89+
from swagger_client.rest import ApiException
90+
from pprint import pprint
91+
92+
# Configure API key authorization: cookieCSRF
93+
configuration = swagger_client.Configuration()
94+
configuration.api_key['csrftoken'] = 'YOUR_API_KEY'
95+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
96+
# configuration.api_key_prefix['csrftoken'] = 'Bearer'
97+
# Configure API key authorization: cookieSession
98+
configuration = swagger_client.Configuration()
99+
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
100+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
101+
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
102+
# Configure API key authorization: headerCSRF
103+
configuration = swagger_client.Configuration()
104+
configuration.api_key['x-csrftoken'] = 'YOUR_API_KEY'
105+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
106+
# configuration.api_key_prefix['x-csrftoken'] = 'Bearer'
107+
# Configure API key authorization: referer
108+
configuration = swagger_client.Configuration()
109+
configuration.api_key['Referer'] = 'YOUR_API_KEY'
110+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
111+
# configuration.api_key_prefix['Referer'] = 'Bearer'
112+
113+
# create an instance of the API class
114+
api_instance = swagger_client.DefaultApi(swagger_client.ApiClient(configuration))
115+
body = swagger_client.GraphqlQuery() # GraphqlQuery | GraphQL query (optional)
116+
117+
try:
118+
api_response = api_instance.graphql_post(body=body)
119+
pprint(api_response)
120+
except ApiException as e:
121+
print("Exception when calling DefaultApi->graphql_post: %s\n" % e)
122+
```
123+
124+
### Parameters
125+
126+
Name | Type | Description | Notes
127+
------------- | ------------- | ------------- | -------------
128+
**body** | [**GraphqlQuery**](GraphqlQuery.md)| GraphQL query | [optional]
129+
130+
### Return type
131+
132+
[**GraphqlResponse**](GraphqlResponse.md)
133+
134+
### Authorization
135+
136+
[cookieCSRF](../README.md#cookieCSRF), [cookieSession](../README.md#cookieSession), [headerCSRF](../README.md#headerCSRF), [referer](../README.md#referer)
137+
138+
### HTTP request headers
139+
140+
- **Content-Type**: application/json
141+
- **Accept**: application/json
142+
143+
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
144+
78145
# **problems_problem_interpret_solution_post**
79146
> Interpretation problems_problem_interpret_solution_post(problem, body=body)
80147

docs/GraphqlQuery.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# GraphqlQuery
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**query** | **str** | |
7+
**variables** | [**GraphqlQueryVariables**](GraphqlQueryVariables.md) | |
8+
**operation_name** | **str** | |
9+
10+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
11+

docs/GraphqlQueryVariables.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# GraphqlQueryVariables
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**title_slug** | **str** | |
7+
8+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
9+

docs/GraphqlQuestion.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# GraphqlQuestion
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**question** | [**GraphqlQuestionDetail**](GraphqlQuestionDetail.md) | |
7+
8+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
9+

docs/GraphqlQuestionDetail.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# GraphqlQuestionDetail
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**content** | **str** | |
7+
**stats** | **str** | | [optional]
8+
**code_definition** | **str** | | [optional]
9+
**sample_test_case** | **str** | | [optional]
10+
**enable_run_code** | **bool** | | [optional]
11+
**meta_data** | **str** | | [optional]
12+
**translated_content** | **str** | | [optional]
13+
14+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
15+

docs/GraphqlResponse.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# GraphqlResponse
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**data** | [**OneOfGraphqlResponseData**](OneOfGraphqlResponseData.md) | |
7+
8+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
9+

docs/OneOfGraphqlResponseData.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# OneOfGraphqlResponseData
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
7+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
8+

example.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from time import sleep
23

34
import swagger_client
@@ -16,6 +17,25 @@
1617

1718
api_instance = swagger_client.DefaultApi(swagger_client.ApiClient(configuration))
1819

20+
graphql_request = swagger_client.GraphqlQuery(
21+
query="""
22+
query getQuestionDetail($titleSlug: String!) {
23+
question(titleSlug: $titleSlug) {
24+
content
25+
stats
26+
codeDefinition
27+
sampleTestCase
28+
enableRunCode
29+
metaData
30+
translatedContent
31+
}
32+
}
33+
""",
34+
variables=swagger_client.GraphqlQueryVariables(title_slug="two-sum"),
35+
operation_name="getQuestionDetail",
36+
)
37+
38+
print(api_instance.graphql_post(body=graphql_request))
1939

2040
# Get stats
2141
api_response = api_instance.api_problems_topic_get(topic="shell")
@@ -45,6 +65,7 @@ def twoSum(self, nums, target):
4565
problem="two-sum", body=test_submission
4666
)
4767

68+
4869
print("Test has been queued. Result:")
4970
print(interpretation_id)
5071

python-client-generated.zip

-58.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)