How to use the ariadne.gql function in ariadne

To help you get started, we’ve selected a few ariadne examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mirumee / ariadne / tests / test_gql_util.py View on Github external
def test_invalid_graphql_query_string_causes_syntax_error():
    with pytest.raises(GraphQLSyntaxError):
        gql(
            """
                query TestQuery {
github mirumee / ariadne / tests / test_gql_util.py View on Github external
def test_valid_graphql_query_string_is_returned_unchanged():
    query = """
        query TestQuery {
            auth
            users {
                id
                username
            }
        }
    """
    result = gql(query)
    assert query == result
github mirumee / ariadne / tests / test_gql_util.py View on Github external
def test_invalid_graphql_schema_string_causes_syntax_error():
    with pytest.raises(GraphQLSyntaxError):
        gql(
            """
                type User {
github mirumee / ariadne / tests / test_gql_util.py View on Github external
def test_valid_graphql_schema_string_is_returned_unchanged():
    sdl = """
        type User {
            username: String!
        }
    """
    result = gql(sdl)
    assert sdl == result
github mirumee / graphql-workshop / 01-basics-final / example.py View on Github external
"""Example 01: The Basics.

Run with::

    $ uvicorn example:app
"""
from ariadne import MutationType, QueryType, gql, make_executable_schema
from ariadne.asgi import GraphQL

# This is our schema
type_defs = gql(
    """
    type Query {
        hello: String!
    }

    type Mutation {
        add(a: Int!, b: Int!): Int!
    }
"""
)

query = QueryType()  # our Query type
mutation = MutationType()  # our Mutation type


@query.field("hello")  # Query.hello
github patrys / django-channels-ariadne / mysite / routing.py View on Github external
import asyncio

from ariadne import gql, ResolverMap
from ariadne.executable_schema import make_executable_schema
from channels.routing import ProtocolTypeRouter, URLRouter
from django.conf.urls import url
from graphql.pyutils import EventEmitter, EventEmitterAsyncIterator
from graphql.subscription import subscribe

from .database import db, init_database, Note
from .graphql import GraphQLHTTPConsumer, GraphQLWebsocketConsumer
from .subscription import SubscriptionAwareResolverMap

SCHEMA = gql(
    """
type Note {
    id: ID!
    title: String
    body: String
}

type Query {
    hello: String!
    notes: [Note!]!
    notesContaining(query: String!): [Note!]!
}

type Mutation {
    createNote(title: String!, body: String!): Note!
    sendMessage(message: String!): Boolean!
github mirumee / graphql-workshop / 02-object-types-final / example.py View on Github external
"""Example 02: Object Types.

Run with::

    $ uvicorn example:app
"""
from ariadne import ObjectType, QueryType, gql, make_executable_schema
from ariadne.asgi import GraphQL

# This is our schema
type_defs = gql(
    """
    type Book {
        title: String!
        year: Int!
        age: Int!
    }

    type Query {
        books: [Book!]!
    }
"""
)

query = QueryType()  # our Query type
github mirumee / graphql-workshop / 02-object-types / example.py View on Github external
"""Example 02: Object Types.

Run with::

    $ uvicorn example:app
"""
from ariadne import ObjectType, QueryType, gql, make_executable_schema
from ariadne.asgi import GraphQL

# This is our schema
type_defs = gql(
    """
    type Book {
        title: String!
        year: Int!
    }

    type Query {
        books: [Book!]!
    }
"""
)

query = QueryType()  # our Query type


@query.field("books")  # Query.books
github mirumee / graphql-workshop / 04-django-channels / example / graphql.py View on Github external
from ariadne import gql, make_executable_schema

# This is our schema
type_defs = gql(
    """
    type Query {
        hello: String!
    }
"""
)

# Create an executable GraphQL schema
schema = make_executable_schema(type_defs, [])
github mirumee / graphql-workshop / 03-django / example / graphql.py View on Github external
from ariadne import gql, make_executable_schema

# This is our schema
type_defs = gql(
    """
    type Query {
        hello: String!
    }
"""
)

# Create an executable GraphQL schema
schema = make_executable_schema(type_defs, [])