GraphQL\Type\Introspection::schemaMetaFieldDef PHP Method

schemaMetaFieldDef() public static method

public static schemaMetaFieldDef ( )
    public static function schemaMetaFieldDef()
    {
        if (!isset(self::$map['__schema'])) {
            self::$map['__schema'] = FieldDefinition::create(['name' => '__schema', 'type' => Type::nonNull(self::_schema()), 'description' => 'Access the current type schema of this server.', 'args' => [], 'resolve' => function ($source, $args, $context, ResolveInfo $info) {
                return $info->schema;
            }]);
        }
        return self::$map['__schema'];
    }

Usage Example

Example #1
0
 /**
  * Not exactly the same as the executor's definition of getFieldDef, in this
  * statically evaluated environment we do not always have an Object type,
  * and need to handle Interface and Union types.
  *
  * @return FieldDefinition
  */
 private static function _getFieldDef(Schema $schema, Type $parentType, Field $fieldAST)
 {
     $name = $fieldAST->name->value;
     $schemaMeta = Introspection::schemaMetaFieldDef();
     if ($name === $schemaMeta->name && $schema->getQueryType() === $parentType) {
         return $schemaMeta;
     }
     $typeMeta = Introspection::typeMetaFieldDef();
     if ($name === $typeMeta->name && $schema->getQueryType() === $parentType) {
         return $typeMeta;
     }
     $typeNameMeta = Introspection::typeNameMetaFieldDef();
     if ($name === $typeNameMeta->name && ($parentType instanceof ObjectType || $parentType instanceof InterfaceType || $parentType instanceof UnionType)) {
         return $typeNameMeta;
     }
     if ($parentType instanceof ObjectType || $parentType instanceof InterfaceType) {
         $fields = $parentType->getFields();
         return isset($fields[$name]) ? $fields[$name] : null;
     }
     return null;
 }
All Usage Examples Of GraphQL\Type\Introspection::schemaMetaFieldDef