コード例 #1
0
        private EventDescription CreateEvent(
            IExecutionContext executionContext)
        {
            IReadOnlyCollection <FieldSelection> selections = executionContext
                                                              .FieldHelper.CollectFields(
                executionContext.Operation.RootType,
                executionContext.Operation.Definition.SelectionSet);

            if (selections.Count == 1)
            {
                FieldSelection selection = selections.Single();
                Dictionary <string, ArgumentValue> argumentValues = selection
                                                                    .CoerceArgumentValues(executionContext.Variables);
                var arguments = new List <ArgumentNode>();

                foreach (KeyValuePair <string, ArgumentValue> argumentValue in
                         argumentValues)
                {
                    IInputType argumentType = argumentValue.Value.Type;
                    object     value        = argumentValue.Value.Value;

                    arguments.Add(new ArgumentNode(
                                      argumentValue.Key,
                                      argumentType.ParseValue(value)));
                }

                return(new EventDescription(selection.Field.Name, arguments));
            }
            else
            {
                // TODO : Error message
                throw new QueryException();
            }
        }