Example #1
0
 def add_directive(self, value: GraphQLDirective) -> None:
     if self._directives.get(value.name):
         raise RedefinedImplementation(
             "new GraphQL directive definition `{}` "
             "overrides existing directive definition `{}`.".format(
                 value.name, repr(self._directives.get(value.name))))
     self._directives[value.name] = value
Example #2
0
 def add_custom_scalar_definition(self, value: GraphQLScalarType) -> None:
     if self._custom_scalars.get(value.name):
         raise RedefinedImplementation(
             "new GraphQL scalar definition `{}` "
             "overrides existing scalar definition `{}`.".format(
                 value.name, repr(self._custom_scalars.get(value.name))))
     self._custom_scalars[value.name] = value
Example #3
0
 def add_enum_definition(self, value: GraphQLEnumType) -> None:
     if self._enums.get(value.name):
         raise RedefinedImplementation(
             "new GraphQL enum definition `{}` "
             "overrides existing enum definition `{}`.".format(
                 value.name, repr(self._enums.get(value.name))))
     self._enums[value.name] = value
Example #4
0
 def add_definition(self, value: GraphQLType) -> None:
     if self._gql_types.get(value.name):
         raise RedefinedImplementation(
             "new GraphQL type definition `{}` "
             "overrides existing type definition `{}`.".format(
                 value.name, repr(self._gql_types.get(value.name))))
     self._gql_types[value.name] = value
Example #5
0
 def add_definition(self, value: GraphQLType) -> None:
     if self._gql_types.get(value.name):
         raise RedefinedImplementation(
             "new GraphQL type definition `{}` "
             "overrides existing type definition `{}`.".format(
                 value.name, repr(self._gql_types.get(value.name))))
     self._gql_types[value.name] = value
     if isinstance(value, GraphQLInputObjectType):
         self._input_types.append(value.name)
Example #6
0
 def add_type_definition(self, type_definition: "GraphQLType") -> None:
     """
     Adds a GraphQLType to the defined type list.
     :param type_definition: GraphQLType to add
     :type type_definition: GraphQLType
     """
     if type_definition.name in self.type_definitions:
         raise RedefinedImplementation(
             "new GraphQL type definition `{}` "
             "overrides existing type definition `{}`.".format(
                 type_definition.name,
                 repr(self.type_definitions.get(type_definition.name)),
             ))
     self.type_definitions[type_definition.name] = type_definition
     if isinstance(type_definition, GraphQLInputObjectType):
         self._input_types.append(type_definition.name)
Example #7
0
 def add_enum_definition(self, enum_definition: "GraphQLEnumType") -> None:
     """
     Adds a GraphQLScalarType to the defined scalar list.
     :param enum_definition: GraphQLEnumType to add
     :type enum_definition: GraphQLEnumType
     """
     if enum_definition.name in self._enum_definitions:
         raise RedefinedImplementation(
             "new GraphQL enum definition `{}` "
             "overrides existing enum definition `{}`.".format(
                 enum_definition.name,
                 repr(self._enum_definitions.get(enum_definition.name)),
             ))
     self._enum_definitions[enum_definition.name] = enum_definition
     self._input_types.append(enum_definition.name)
     self.add_type_definition(enum_definition)
Example #8
0
 def add_scalar_definition(self,
                           scalar_definition: "GraphQLScalarType") -> None:
     """
     Adds a GraphQLScalarType to the defined scalar list.
     :param scalar_definition: GraphQLScalarType to add
     :type scalar_definition: GraphQLScalarType
     """
     if scalar_definition.name in self._scalar_definitions:
         raise RedefinedImplementation(
             "new GraphQL scalar definition `{}` "
             "overrides existing scalar definition `{}`.".format(
                 scalar_definition.name,
                 repr(self._scalar_definitions.get(scalar_definition.name)),
             ))
     self._scalar_definitions[scalar_definition.name] = scalar_definition
     self._input_types.append(scalar_definition.name)
     self.add_type_definition(scalar_definition)
Example #9
0
 def add_directive_definition(
         self, directive_definition: "GraphQLDirective") -> None:
     """
     Adds a GraphQLDirective to the defined directive list.
     :param directive_definition: GraphQLDirective to add
     :type directive_definition: GraphQLDirective
     """
     if directive_definition.name in self._directive_definitions:
         raise RedefinedImplementation(
             "new GraphQL directive definition `{}` "
             "overrides existing directive definition `{}`.".format(
                 directive_definition.name,
                 repr(
                     self._directive_definitions.get(
                         directive_definition.name)),
             ))
     self._directive_definitions[
         directive_definition.name] = directive_definition