Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ To run code generation manually:

```shell
pip install ariadne-codegen
ariadne-codegen
python -m ariadne_codegen

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess it depends on local setup

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes it works, sometimes not on my side.. not yet found the ideal setup indeed

```

ariadne-codegen runs automatically via pre-commit hooks and CI/CD when GraphQL files are modified.
Expand Down
15 changes: 15 additions & 0 deletions openhexa/cli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
from datetime import datetime
from importlib.metadata import version
from pathlib import Path
from typing import Any
from zipfile import ZipFile

import click
import docker
import httpx
import requests
from docker.models.containers import Container
from graphql import build_client_schema, build_schema, get_introspection_query
Expand Down Expand Up @@ -760,6 +762,9 @@ def execute(self, query, **kwargs):
"""Decorate parent execute method to log the GraphQL query and response."""
_detect_graphql_breaking_changes(token=self.token)

if self.token is None:
raise InvalidTokenError("No token found for workspace")

if settings.debug:
click.echo("")
click.echo("Graphql Query:")
Expand All @@ -776,3 +781,13 @@ def execute(self, query, **kwargs):
click.echo(f"Response: {response}")

return response

def get_data(self, response: httpx.Response) -> dict[str, Any]:
"""Get the data from the response, handling errors and authentication issues."""
try:
data = super().get_data(response)
except Exception as e:
if "Resolver requires an authenticated user" in str(e):
raise InvalidTokenError("No or invalid token found for workspace, please check your configuration.")
raise
return data
26 changes: 0 additions & 26 deletions openhexa/graphql/graphql_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@
MembershipRole,
MessagePriority,
OrderByDirection,
OrganizationMembershipRole,
ParameterType,
ParameterWidget,
PermissionMode,
Expand Down Expand Up @@ -328,20 +327,6 @@
InviteWorkspaceMemberInviteWorkspaceMember,
InviteWorkspaceMemberInviteWorkspaceMemberWorkspaceMembership,
)
from .organization import (
Organization,
OrganizationOrganization,
OrganizationOrganizationPermissions,
OrganizationOrganizationWorkspaces,
OrganizationOrganizationWorkspacesItems,
OrganizationOrganizationWorkspacesItemsCountries,
)
from .organizations import (
Organizations,
OrganizationsOrganizations,
OrganizationsOrganizationsWorkspaces,
OrganizationsOrganizationsWorkspacesItems,
)
from .pipeline import (
Pipeline,
PipelinePipelineByCode,
Expand Down Expand Up @@ -610,18 +595,7 @@
"MembershipRole",
"MessagePriority",
"OrderByDirection",
"Organization",
"OrganizationInput",
"OrganizationMembershipRole",
"OrganizationOrganization",
"OrganizationOrganizationPermissions",
"OrganizationOrganizationWorkspaces",
"OrganizationOrganizationWorkspacesItems",
"OrganizationOrganizationWorkspacesItemsCountries",
"Organizations",
"OrganizationsOrganizations",
"OrganizationsOrganizationsWorkspaces",
"OrganizationsOrganizationsWorkspacesItems",
"ParameterInput",
"ParameterType",
"ParameterWidget",
Expand Down
60 changes: 0 additions & 60 deletions openhexa/graphql/graphql_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
InviteWorkspaceMember,
InviteWorkspaceMemberInviteWorkspaceMember,
)
from .organization import Organization, OrganizationOrganization
from .organizations import Organizations, OrganizationsOrganizations
from .pipeline import Pipeline, PipelinePipelineByCode
from .pipelines import Pipelines, PipelinesPipelines
from .remove_webapp_from_favorites import (
Expand Down Expand Up @@ -796,64 +794,6 @@ def delete_connection(
data = self.get_data(response)
return DeleteConnection.model_validate(data).delete_connection

def organization(
self, id: Any, **kwargs: Any
) -> Optional[OrganizationOrganization]:
query = gql(
"""
query Organization($id: UUID!) {
organization(id: $id) {
id
name
shortName
workspaces {
items {
slug
name
countries {
code
}
}
}
permissions {
createWorkspace
archiveWorkspace
}
}
}
"""
)
variables: Dict[str, object] = {"id": id}
response = self.execute(
query=query, operation_name="Organization", variables=variables, **kwargs
)
data = self.get_data(response)
return Organization.model_validate(data).organization

def organizations(self, **kwargs: Any) -> List[OrganizationsOrganizations]:
query = gql(
"""
query Organizations {
organizations {
id
name
workspaces {
items {
slug
name
}
}
}
}
"""
)
variables: Dict[str, object] = {}
response = self.execute(
query=query, operation_name="Organizations", variables=variables, **kwargs
)
data = self.get_data(response)
return Organizations.model_validate(data).organizations

def get_users(
self, query: str, workspace_slug: str, **kwargs: Any
) -> List[GetUsersUsers]:
Expand Down
6 changes: 0 additions & 6 deletions openhexa/graphql/graphql_client/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,12 +461,6 @@ class OrderByDirection(str, Enum):
DESC = "DESC"


class OrganizationMembershipRole(str, Enum):
ADMIN = "ADMIN"
MEMBER = "MEMBER"
OWNER = "OWNER"


class ParameterType(str, Enum):
bool = "bool"
custom = "custom"
Expand Down
1 change: 0 additions & 1 deletion openhexa/graphql/graphql_client/input_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ class CreateWorkspaceInput(BaseModel):
description: Optional[str] = None
load_sample_data: Optional[bool] = Field(alias="loadSampleData", default=None)
name: str
organization_id: Optional[Any] = Field(alias="organizationId", default=None)
slug: Optional[str] = None


Expand Down
66 changes: 33 additions & 33 deletions openhexa/graphql/queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -305,39 +305,39 @@ mutation DeleteConnection($input: DeleteConnectionInput!) {
}
}

query Organization($id: UUID!) {
organization(id: $id) {
id
name
shortName
workspaces {
items {
slug
name
countries {
code
}
}
}
permissions {
createWorkspace
archiveWorkspace
}
}
}

query Organizations {
organizations {
id
name
workspaces {
items {
slug
name
}
}
}
}
#query Organization($id: UUID!) {
# organization(id: $id) {
# id
# name
# shortName
# workspaces {
# items {
# slug
# name
# countries {
# code
# }
# }
# }
# permissions {
# createWorkspace
# archiveWorkspace
# }
# }
#}
#
#query Organizations {
# organizations {
# id
# name
# workspaces {
# items {
# slug
# name
# }
# }
# }
#}

query GetUsers($query: String!, $workspaceSlug: String!) {
users(query: $query, workspaceSlug: $workspaceSlug) {
Expand Down
57 changes: 6 additions & 51 deletions openhexa/graphql/schema.generated.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,6 @@ input CreateWorkspaceInput {
description: String
loadSampleData: Boolean
name: String!
organizationId: UUID
slug: String
}

Expand Down Expand Up @@ -2452,26 +2451,14 @@ type Organization {
"""The unique identifier of the organization."""
id: UUID!

"""The members of the organization."""
members(page: Int, perPage: Int): OrganizationMembershipPage!

"""The name of the organization."""
name: String!

"""The permissions the current user has in the organization."""
permissions: OrganizationPermissions!

"""The short name of the organization."""
shortName: String

"""The type of the organization."""
type: String!

"""The URL of the organization."""
url: String!

"""The workspaces associated with the organization."""
workspaces(page: Int, perPage: Int): WorkspacePage!
}

"""
Expand All @@ -2494,36 +2481,6 @@ input OrganizationInput {
url: String
}

"""Represents a membership in an organization."""
type OrganizationMembership {
createdAt: DateTime!
id: UUID!
organization: Organization!
role: OrganizationMembershipRole!
updatedAt: DateTime
user: User!
}

"""Represents a page of organization memberships."""
type OrganizationMembershipPage {
items: [WorkspaceMembership!]!
pageNumber: Int!
totalItems: Int!
totalPages: Int!
}

"""Represents the role of a organization membership."""
enum OrganizationMembershipRole {
ADMIN
MEMBER
OWNER
}

type OrganizationPermissions {
archiveWorkspace: Boolean!
createWorkspace: Boolean!
}

"""Represents an input parameter of a pipeline."""
input ParameterInput {
choices: [Generic!]
Expand Down Expand Up @@ -3063,7 +3020,6 @@ type Query {
me: Me!
metadataAttributes(targetId: OpaqueID!): [MetadataAttribute]!
notebooksUrl: URL!
organization(id: UUID!): Organization

"""Retrieves a list of organizations."""
organizations: [Organization!]!
Expand All @@ -3086,11 +3042,11 @@ type Query {

"""Retrieves a page of pipelines ordered by relevant name."""
pipelines(name: String, page: Int, perPage: Int, search: String, workspaceSlug: String): PipelinesPage!
searchDatabaseTables(organizationId: UUID, page: Int = 1, perPage: Int = 15, query: String!, workspaceSlugs: [String]): DatabaseTableResultPage!
searchDatasets(organizationId: UUID, page: Int = 1, perPage: Int = 15, query: String!, workspaceSlugs: [String]): DatasetResultPage!
searchFiles(organizationId: UUID, page: Int = 1, perPage: Int = 15, query: String!, workspaceSlugs: [String]): FileResultPage!
searchPipelineTemplates(organizationId: UUID, page: Int = 1, perPage: Int = 15, query: String!, workspaceSlugs: [String]): PipelineTemplateResultPage!
searchPipelines(organizationId: UUID, page: Int = 1, perPage: Int = 15, query: String!, workspaceSlugs: [String]): PipelineResultPage!
searchDatabaseTables(page: Int = 1, perPage: Int = 15, query: String!, workspaceSlugs: [String]!): DatabaseTableResultPage!
searchDatasets(page: Int = 1, perPage: Int = 15, query: String!, workspaceSlugs: [String]!): DatasetResultPage!
searchFiles(page: Int = 1, perPage: Int = 15, query: String!, workspaceSlugs: [String]!): FileResultPage!
searchPipelineTemplates(page: Int = 1, perPage: Int = 15, query: String!, workspaceSlugs: [String]!): PipelineTemplateResultPage!
searchPipelines(page: Int = 1, perPage: Int = 15, query: String!, workspaceSlugs: [String]!): PipelineResultPage!
team(id: UUID!): Team
teams(page: Int, perPage: Int, term: String): TeamPage!

Expand All @@ -3104,7 +3060,7 @@ type Query {
webapp(id: UUID!): Webapp
webapps(favorite: Boolean, page: Int, perPage: Int, workspaceSlug: String): WebappsPage!
workspace(slug: String!): Workspace
workspaces(organizationId: UUID, page: Int, perPage: Int, query: String): WorkspacePage!
workspaces(page: Int, perPage: Int, query: String): WorkspacePage!
}

"""
Expand Down Expand Up @@ -4147,7 +4103,6 @@ type Workspace {
invitations(includeAccepted: Boolean, page: Int, perPage: Int): WorkspaceInvitationPage!
members(page: Int, perPage: Int): WorkspaceMembershipPage!
name: String!
organization: Organization
permissions: WorkspacePermissions!
slug: String!
updatedAt: DateTime
Expand Down