question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run query from Postman

See original GitHub issue

Hi guys. First of all, congrats for this very useful lib.

I wrote a very basic mutation for file upload:

class TestMutation(graphene.Mutation):
    class Arguments:
        sql_file = Upload()

    Output = OperationStatusRetType

    def mutate(self, info, sql_file_ref):
            sql_file = info.context.FILES.get(sql_file_ref)
            sql_query_template = sql_file.read().decode('utf-8')
            sql_file_names = sql_file.names
            in_memory_file = io.StringIO(sql_query_template)
            put_s3_object(s3, AWS_DEFAULT_S3_BUCKET, in_memory_file.getvalue(), sql_file_names.split('/')[-1])

        return AddDatasetRetType(sqlFilePath=sql_file_names.split('/')[-1],
                                 operationStatus=OperationStatusRetType(success=True))

and I consume it this way:

mutation Test {
  testMutation(sql_file: "test.png") {
    success
    error
  }
}

I would like to test it with Postman, posting the file using the POST form-data option, like in the pic:

image

but I get the error “Must provide query string” as generally in GraphQL the querystring should be in the form body.

In the headers “Content-Type” is “application/graphql”.

Do you know how I can test my GraphQL endpoint using Postman? Also is still not clear to me if I need to assign a value to the Upload field (“sql_file” in this case) or it can be left empty.

Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:12

github_iconTop GitHub Comments

4reactions
davidroecacommented, Aug 10, 2019

@gj1118 looks like you put the operations field in the name section of the file. If we’re following the example verbatim in insomnia, you’ll need to do a multipart post with 3 parameters:

  1. A field named operations with the value {"query": "mutation ($file: Upload) { myUpload(fileIn: $file) { ok }}", "variables": { "file": null }}
  2. A field named map with the value { "0": ["variables.file"]}
  3. A file field named 0 with the file you’re uploading set as the value
1reaction
davidroecacommented, Aug 10, 2019

Ah sorry, didn’t read the entire thing. Since postid is a string, you’ll need to change the postid variable in the operations from null to the string you want, and you can remove all references to “1”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use Postman to Run SQL Queries on Drill Data Sources
You can run Drill queries from Postman, a Chrome browser extension and HTTP client for testing web services. To run Drill queries from...
Read more >
Postman to run SQL Queries:. Reading database ... - Medium
Open Command Prompt. · Open the apache-drill- folder. · Go to the bin directory. For example: cd bin · Type the following command...
Read more >
Building requests | Postman Learning Center
You can send GraphQL queries with your Postman requests by selecting the GraphQL tab in the request Body. Enter your code in the...
Read more >
Databases - Postman
**These setups are typically not something you would run on production, ... to see the full API for how you can query different...
Read more >
EXECUTE A SOQL QUERY IN POSTMAN. - Nanostuffs
EXECUTE A SOQL QUERY IN POSTMAN. · 1. Using SOQL query to retrieve data from SF object. · 2. The following query requests...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found