Change extrapolation type from Python running in the background
You can't really directly set the context.area.type, or any context property for that matter - it is a read only reflection of the current state of your scene.

To use the graph editor's operators under bpy.ops.graph, you need to override the context for the operator to "make it think" it's running within the graph editor. Here's an example how to do this for another operator.

But instead I would suggest changing the interpolation and handle types using lower level code instead of using the graph editor's operators. Here's a chunk of code that will do this for all of the active object's animation curves:

import bpy
C = bpy.context
o = C.object

# Iterate over all the objects animation function curves
for fc in o.animation_data.action.fcurves:
    fc.extrapolation = 'LINEAR' # Set extrapolation type

    # Iterate over this fcurve's keyframes and set handles to vector
    for kp in fc.keyframe_points:
        kp.handle_left_type  = 'VECTOR'
        kp.handle_right_type = 'VECTOR'