<s> from ... error import GraphQLError <EOL> from . base import ValidationRule <EOL> class UniqueInputFieldNames ( ValidationRule ) : <EOL> __slots__ = '<STR_LIT>' , '<STR_LIT>' <EOL> def __init__ ( self , context ) : <EOL> super ( UniqueInputFieldNames , self ) . __init__ ( context ) <EOL> self . known_names = { } <EOL> self . known_names_stack = [ ] <EOL> def enter_ObjectValue ( self , node , key , parent , path , ancestors ) : <EOL> self . known_names_stack . append ( self . known_names ) <EOL> self . known_names = { } <EOL> def leave_ObjectValue ( self , node , key , parent , path , ancestors ) : <EOL> self . known_names = self . known_names_stack . pop ( ) <EOL> def enter_ObjectField ( self , node , key , parent , path , ancestors ) : <EOL> field_name = node . name . value <EOL> if field_name in self . known_names : <EOL> self . context . report_error ( GraphQLError ( <EOL> self . duplicate_input_field_message ( field_name ) , <EOL> [ self . known_names [ field_name ] , node . name ] <EOL> ) ) <EOL> else : <EOL> self . known_names [ field_name ] = node . name <EOL> return False <EOL> @ staticmethod <EOL> def duplicate_input_field_message ( field_name ) : <EOL> return '<STR_LIT>' . format ( field_name ) </s>
