Exemplo n.º 1
0
 public SchemaField(ISchemaQueryType <Info> declaringType, GraphQLField field, Schema schema)
 {
     DeclaringType = declaringType;
     _field        = field;
     _schema       = schema;
     if (_field.Type.IsScalar)
     {
         var varType = _schema.GraphQLSchema.VariableTypes.VariableTypeOf(_field.Type.CLRType);
         FieldType = SchemaFieldType <Info> .NewValueField(varType);
     }
     else
     {
         FieldType = SchemaFieldType <Info> .NewQueryField(_schema.OfType(_field.Type));;
     }
     Arguments = _field.Arguments.ToDictionary(a => a.ArgumentName);
 }
Exemplo n.º 2
0
 public SchemaField(ISchemaQueryType <Info> declaringType, GraphQLField field, Schema schema)
 {
     DeclaringType = declaringType;
     _field        = field;
     _schema       = schema;
     if (_field.Type.TypeKind == TypeKind.SCALAR)
     {
         var varType = _schema.GraphQLSchema.VariableTypes.VariableTypeOf(_field.Type.CLRType);
         if (varType?.Type == null)
         {
             throw new Exception("Field has unknown return type. " + declaringType.TypeName + "." + _field.Name);
         }
         FieldType = SchemaFieldType <Info> .NewValueField(varType);
     }
     else
     {
         FieldType = SchemaFieldType <Info> .NewQueryField(_schema.OfType(_field.Type));;
     }
     Arguments = _field.Arguments.ToDictionary(a => a.ArgumentName);
 }