Пример #1
0
        public SchemaRepository()
        {
            this.outputBindings = new Dictionary <Type, GraphQLBaseType>();
            this.inputBindings  = new Dictionary <Type, GraphQLInputType>();
            this.directives     = new Dictionary <string, GraphQLDirectiveType>();

            var graphQLInt     = new GraphQLInt();
            var graphQLLong    = new GraphQLLong();
            var graphQLFloat   = new GraphQLFloat();
            var graphQLBoolean = new GraphQLBoolean();
            var graphQLString  = new GraphQLString();
            var graphQLID      = new GraphQLID();

            this.outputBindings.Add(typeof(string), graphQLString);
            this.inputBindings.Add(typeof(string), graphQLString);

            this.outputBindings.Add(typeof(int), graphQLInt);
            this.outputBindings.Add(typeof(long), graphQLLong);
            this.outputBindings.Add(typeof(float), graphQLFloat);
            this.outputBindings.Add(typeof(bool), graphQLBoolean);

            this.inputBindings.Add(typeof(int), graphQLInt);
            this.inputBindings.Add(typeof(long), graphQLLong);
            this.inputBindings.Add(typeof(float), graphQLFloat);
            this.inputBindings.Add(typeof(bool), graphQLBoolean);

            this.outputBindings.Add(typeof(ID), graphQLID);
            this.inputBindings.Add(typeof(ID), graphQLID);
        }
        public override bool PreExecutionIncludeFieldIntoResult(
            GraphQLDirective directive,
            ISchemaRepository schemaRepository)
        {
            var argument    = directive.Arguments.Single(e => e.Name.Value == "if");
            var booleanType = new GraphQLBoolean();

            var result = booleanType.GetFromAst(argument.Value, schemaRepository);

            return(!(bool)result.Value);
        }