Skip to content

Commit

Permalink
Remove per object on_conflict type
Browse files Browse the repository at this point in the history
  • Loading branch information
Guido committed Apr 16, 2021
1 parent 4cce8ac commit 580e80d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/graphql_sqlalchemy/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .graphql_types import get_graphql_type_from_column
from .helpers import get_table
from .inputs import (
get_conflict_input_type,
ON_CONFLICT_INPUT,
get_inc_input_type,
get_insert_input_type,
get_order_input_type,
Expand Down Expand Up @@ -43,14 +43,14 @@ def make_pk_args(model: DeclarativeMeta) -> GraphQLArgumentMap:
def make_insert_args(model: DeclarativeMeta, inputs: Inputs) -> GraphQLArgumentMap:
return {
"objects": GraphQLArgument(GraphQLNonNull(GraphQLList(GraphQLNonNull(get_insert_input_type(model, inputs))))),
"on_conflict": GraphQLArgument(get_conflict_input_type(model, inputs)),
"on_conflict": GraphQLArgument(ON_CONFLICT_INPUT),
}


def make_insert_one_args(model: DeclarativeMeta, inputs: Inputs) -> GraphQLArgumentMap:
return {
"object": GraphQLArgument(get_insert_input_type(model, inputs)),
"on_conflict": GraphQLArgument(get_conflict_input_type(model, inputs)),
"on_conflict": GraphQLArgument(ON_CONFLICT_INPUT),
}


Expand Down
18 changes: 3 additions & 15 deletions src/graphql_sqlalchemy/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from .helpers import get_relationships, get_table
from .names import (
get_graphql_type_comparison_name,
get_model_conflict_input_name,
get_model_inc_input_type_name,
get_model_insert_input_name,
get_model_order_by_input_name,
Expand All @@ -26,6 +25,9 @@
from .types import Inputs

ORDER_BY_ENUM = GraphQLEnumType("order_by", {"desc": "desc", "asc": "asc"})
ON_CONFLICT_INPUT = GraphQLInputObjectType("on_conflict_input", {
"merge": GraphQLInputField(GraphQLNonNull(GraphQLBoolean)),
})


def get_comparison_input_type(column: Column, inputs: Inputs) -> GraphQLInputObjectType:
Expand Down Expand Up @@ -103,20 +105,6 @@ def get_insert_input_type(model: DeclarativeMeta, inputs: Inputs) -> GraphQLInpu
return inputs[type_name]


def get_conflict_input_type(model: DeclarativeMeta, inputs: Inputs) -> GraphQLInputObjectType:
type_name = get_model_conflict_input_name(model)
if type_name in inputs:
return inputs[type_name]

fields = {
"merge": GraphQLInputField(GraphQLNonNull(GraphQLBoolean)),
}

input_type = GraphQLInputObjectType(type_name, fields)
inputs[type_name] = input_type
return input_type


def get_inc_input_type(model: DeclarativeMeta, inputs: Inputs) -> GraphQLInputObjectType:
type_name = get_model_inc_input_type_name(model)
if type_name in inputs:
Expand Down
4 changes: 0 additions & 4 deletions src/graphql_sqlalchemy/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ def get_model_mutation_response_object_name(model: DeclarativeMeta) -> str:
return f"{get_table_name(model)}_mutation_response"


def get_model_conflict_input_name(model: DeclarativeMeta) -> str:
return f"{get_table_name(model)}_on_conflict"


def get_model_constraint_enum_name(model: DeclarativeMeta) -> str:
return f"{get_table_name(model)}_constraint"

Expand Down

0 comments on commit 580e80d

Please sign in to comment.