Change the code below the "# Add the cookie to the response object" part
from ariadne import make_executable_schema, gql
type_defs = gql("""
type Query {
example: String!
}
""")
@app.route("/graphql", methods=["POST"])
def graphql():
def resolve_example(_, info, **kwargs):
# Add the cookie to the response object
info.context["response"].set_cookie("my-custom-cookie", "my-custom-value")
return "Example"
resolvers = {
"Query": {
"example": resolve_example
}
}
schema = make_executable_schema(type_defs, resolvers)
return GraphQLView.as_view(schema=schema)(request)