Пример #1
0
def create_resolve_info(schema,
                        request_string,
                        variables=None,
                        return_type=None):
    exe_context = create_execution_context(schema, request_string, variables)
    parent_type = get_operation_root_type(schema, exe_context.operation)
    field_asts = get_field_asts_from_execution_context(exe_context)

    field_ast = field_asts[0]
    field_name = field_ast.name.value

    if return_type is None:
        field_def = get_field_def(schema, parent_type, field_name)
        if not field_def:
            return Undefined
        return_type = field_def.type

    # The resolve function's optional third argument is a context value that
    # is provided to every resolve function within an execution. It is commonly
    # used to represent an authenticated user, or request-specific caches.
    return GraphQLResolveInfo(
        field_name,
        field_asts,
        return_type,
        parent_type,
        Path(None, 0, None),
        schema,
        exe_context.fragments,
        exe_context.root_value,
        exe_context.operation,
        exe_context.variable_values,
        exe_context.context_value,
        exe_context.is_awaitable,
    )
Пример #2
0
 def _create_resolve_info(self, field_name, field_asts, return_type, parent_type):
     return GraphQLResolveInfo(
         field_name,
         field_asts,
         return_type,
         parent_type,
         Path(None, 0, None),
         schema=self.root_info.schema,
         fragments=self.root_info.fragments,
         root_value=self.root_info.root_value,
         operation=self.root_info.operation,
         variable_values=self.root_info.variable_values,
         context=self.root_info.context,
         is_awaitable=self.root_info.is_awaitable,
     )