Skip to content

Commit

Permalink
refactor: clarify the top level graphene query/mutation/subscription (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rexledesma committed Nov 29, 2021
1 parent 5a83e5a commit 9d9e937
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 27 deletions.
12 changes: 9 additions & 3 deletions js_modules/dagit/packages/core/src/graphql/schema.graphql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ describe('ApolloTestProvider', () => {
expect(result.length).toBe(1);
});

it('allows overriding with mocked `Query` values', async () => {
it('allows overriding with mocked `DagitQuery` values', async () => {
const mocks = {
Query: () => ({
DagitQuery: () => ({
version: () => '1234',
}),
};
Expand Down
2 changes: 1 addition & 1 deletion js_modules/dagit/packages/core/src/testing/defaultMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const defaultMocks = {
solids: () => new MockList(2),
modes: () => new MockList(1),
}),
Query: () => ({
DagitQuery: () => ({
version: () => 'x.y.z',
}),
Repository: () => ({
Expand Down
6 changes: 3 additions & 3 deletions python_modules/dagit/dagit_tests/starlette/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_graphql_get(empty_app):
"/graphql?query={__typename}",
)
assert response.status_code == 200, response.text
assert response.json() == {"data": {"__typename": "Query"}}
assert response.json() == {"data": {"__typename": "DagitQuery"}}


def test_graphql_post(empty_app):
Expand All @@ -59,14 +59,14 @@ def test_graphql_post(empty_app):
"/graphql?query={__typename}",
)
assert response.status_code == 200, response.text
assert response.json() == {"data": {"__typename": "Query"}}
assert response.json() == {"data": {"__typename": "DagitQuery"}}

response = client.post(
"/graphql",
json={"query": "{__typename}"},
)
assert response.status_code == 200, response.text
assert response.json() == {"data": {"__typename": "Query"}}
assert response.json() == {"data": {"__typename": "DagitQuery"}}


def test_graphql_ws_error(empty_app):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import graphene

from .roots.mutation import GrapheneMutation
from .roots.query import GrapheneQuery
from .roots.subscription import GrapheneSubscription
from .roots.mutation import GrapheneDagitMutation
from .roots.query import GrapheneDagitQuery
from .roots.subscription import GrapheneDagitSubscription


def types():
Expand Down Expand Up @@ -68,8 +68,8 @@ def types():

def create_schema():
return graphene.Schema(
query=GrapheneQuery,
mutation=GrapheneMutation,
subscription=GrapheneSubscription,
query=GrapheneDagitQuery,
mutation=GrapheneDagitMutation,
subscription=GrapheneDagitSubscription,
types=types(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,10 @@ def mutate(self, graphene_info, **kwargs):
return action


class GrapheneMutation(graphene.ObjectType):
class GrapheneDagitMutation(graphene.ObjectType):
class Meta:
name = "DagitMutation"

launch_pipeline_execution = GrapheneLaunchRunMutation.Field()
launch_run = GrapheneLaunchRunMutation.Field()
launch_pipeline_reexecution = GrapheneLaunchRunReexecutionMutation.Field()
Expand All @@ -533,6 +536,3 @@ class GrapheneMutation(graphene.ObjectType):
resume_partition_backfill = GrapheneResumeBackfillMutation.Field()
cancel_partition_backfill = GrapheneCancelBackfillMutation.Field()
log_telemetry = GrapheneLogTelemetryMutation.Field()

class Meta:
name = "Mutation"
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@
from .pipeline import GrapheneGraphOrError, GraphenePipelineOrError


class GrapheneQuery(graphene.ObjectType):
class GrapheneDagitQuery(graphene.ObjectType):
class Meta:
name = "DagitQuery"

version = graphene.NonNull(graphene.String)

repositoriesOrError = graphene.NonNull(GrapheneRepositoriesOrError)
Expand Down Expand Up @@ -242,9 +245,6 @@ class GrapheneQuery(graphene.ObjectType):

permissions = graphene.Field(non_null_list(GraphenePermission))

class Meta:
name = "Query"

def resolve_repositoriesOrError(self, graphene_info):
return fetch_repositories(graphene_info)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
from ..pipelines.subscription import GraphenePipelineRunLogsSubscriptionPayload


class GrapheneSubscription(graphene.ObjectType):
class GrapheneDagitSubscription(graphene.ObjectType):
class Meta:
name = "DagitSubscription"

pipelineRunLogs = graphene.Field(
graphene.NonNull(GraphenePipelineRunLogsSubscriptionPayload),
runId=graphene.Argument(graphene.NonNull(graphene.ID)),
Expand All @@ -28,9 +31,6 @@ class GrapheneSubscription(graphene.ObjectType):
graphene.NonNull(GrapheneLocationStateChangeSubscription)
)

class Meta:
name = "Subscription"

def resolve_pipelineRunLogs(self, graphene_info, runId, after=None):
return get_pipeline_run_observable(graphene_info, runId, after)

Expand Down

0 comments on commit 9d9e937

Please sign in to comment.