Coder Social home page Coder Social logo

Comments (3)

half-coconut avatar half-coconut commented on July 20, 2024 1
import requests
from graphql_query import Argument, Directive, Field, Operation, Query, Variable

dd = 'str1 str2 str3 str4 str5 str6'


class demo:
    def getData(self, sort_field, reverse, data_type, input):
        get_asset = Query(
            name="get_data",
            arguments=[Argument(name="sort_field", value=sort_field),
                       Argument(name="reverse", value=reverse),
                       Argument(name="data_type", value=data_type),
                       Argument(name="input", value=input),
                       ],
            fields=[
                Field(name="color", fields=[dd]),
                Field(name="count")
            ]
        )
        operation = Operation(type="", queries=[get_asset])
        return operation.render()

    def result(self):
        return {
            "query": self.getData(sort_field='"green",', reverse='false,', data_type='"red",',
                                   input='["a","b","c","d","e","f"],')
        }


print(demo().result())
data = demo().result()

your_url = ''
your_header = {}

# method 1
r = requests.post(url=your_url, json=data, headers=your_header)
print(r.status_code)
print(r.json())


# def test_query():
#     # method 2
#     r = requests.post(url=your_url, json=data, headers=your_header)
#     print(r.status_code)
#     print(r.json())

'''
Replace with your URL, header, and parameters
then apply Method 1 and Method 2 separately. 
Method 1 succeeds, while Method 2 results in an error.

Python 3.11.5
pytest 7.4.2
pydantic 2.5.3
pydantic_core 2.14.6
graphql_query 1.2.0
'''

from graphql-query.

denisart avatar denisart commented on July 20, 2024

Hello, thank for report of this bug!

I will check this problem soon. Can you give an example of a test with this error?

What are the versions of your requirements (python, pytest, pydantic, graphql-query)?

from graphql-query.

denisart avatar denisart commented on July 20, 2024

The following PR fixed your problem #32
Available in version 1.3.0 https://github.com/denisart/graphql-query/releases/tag/v1.3.0

from graphql-query.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.