Send GraphQL Mutation#

If the Flow is configured with GraphQL endpoint, then you can use Jina Client mutate() to fetch data via GraphQL mutations:

Only available for docarray<0.30

This feature is only available when using docarray<0.30.

from jina import Client

PORT = ...
c = Client(port=PORT)
mut = '''
        mutation {
            docs(data: {text: "abcd"}) { 
                id
                matches {
                    embedding
                }
            } 
        }
    '''
response = c.mutate(mutation=mut)

Note that response here is Dict not a DocumentArray. This is because GraphQL allows the user to specify only certain fields that they want to have returned, so the output might not be a valid DocumentArray, it can be only a string.

Mutations and arguments#

The Flow GraphQL API exposes the mutation docs, which sends its inputs to the Flow’s Executors, just like HTTP post as described above.

A GraphQL mutation takes the same set of arguments used in HTTP.

The response from GraphQL can include all fields available on a DocumentArray.

See Also

For more details on the GraphQL format of Document and DocumentArray, see the documentation page or developer reference.

Fields#

The available fields in the GraphQL API are defined by the Document Strawberry type.

Essentially, you can ask for any property of a Document, including embedding, text, tensor, id, matches, tags, and more.