Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the raw GraphQL schema instead of one generated from our models #103

Merged
merged 4 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions pydrawise/client.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
"""Client library for interacting with Hydrawise's cloud API."""

import logging
from datetime import datetime
from functools import cache
from importlib import resources
import logging

from apischema.graphql import graphql_schema
from gql import Client
from gql.dsl import DSLField, DSLMutation, DSLQuery, DSLSchema, DSLSelectable, dsl_gql
from gql.transport.aiohttp import AIOHTTPTransport
from gql.transport.aiohttp import log as gql_log
from graphql import GraphQLSchema
from gql.transport.aiohttp import AIOHTTPTransport, log as gql_log
from graphql import GraphQLSchema, build_ast_schema, parse

from .auth import Auth
from .base import HydrawiseBase
from .exceptions import MutationError
from .schema import (
Controller,
DateTime,
Mutation,
StatusCodeAndSummary,
Query,
User,
Zone,
ZoneSuspension,
Expand All @@ -34,10 +32,8 @@

@cache
def _get_schema() -> GraphQLSchema:
return graphql_schema(
query=[getattr(Query, m) for m in Query.__abstractmethods__],
mutation=[getattr(Mutation, m) for m in Mutation.__abstractmethods__],
)
schema_text = resources.files(__package__).joinpath("hydrawise.graphql").read_text()
return build_ast_schema(parse(schema_text))


class Hydrawise(HydrawiseBase):
Expand Down
Loading