serverless / serverless-graphql

Serverless GraphQL Examples for AWS AppSync and Apollo
https://www.serverless.com
MIT License
2.72k stars 364 forks source link

Invalid mapping expression specified: * #67

Closed sixtatami closed 7 years ago

sixtatami commented 7 years ago

Hi Nik, we talked on Gitter.

what did not work for me:

if I run the code exactly as you provided I get following error:

    Serverless Error ---------------------------------------

            An error occurred while provisioning your stack: ApiGatewayMethodGraphqlPost
            - Invalid mapping expression specified: Validation Result:
            warnings : [], errors : [Invalid mapping expression
            specified: *].

    Get Support --------------------------------------------
            Docs:          docs.serverless.com
            Bugs:          github.com/serverless/serverless/issues

    Your Environment Infomation -----------------------------
            OS:                 darwin
            Node Version:       7.0.0
            Serverless Version: 1.0.3

what I tried:

based on https://serverless.com/framework/docs/providers/aws/events/apigateway/ at # Enabling CORS with the Lambda Integration Method it is not needed to define Access-Control-Allow-Methods, as this is set automatically.

I did delete following from the serverless.yaml:

    response:
      headers:
        Access-Control-Allow-Origin: "*"

then it deploys as described in your readme.

However, now my browser throws a:

    No 'Access-Control-Allow-Origin' header is present on the requested resource.
    Origin 'xxxx.s3-website-us-east-1.amazonaws.com' is therefore not allowed access. 
    The response had HTTP status code 502.

Now I was wondering if I should include "'Access-Control-Allow-Origin': '*'" in the returned headers. However apparently this is only needed with a proxy setup.

Well I am bit lost here.

Maybe it is something different I have overlooked that kept my from deploying in the first place?

Thanks a lot for your help.

Cheers Andreas

one more thing: it might be good to say briefly in the readme that the AWS Command line tool is needed to be installed.

sixtatami commented 7 years ago

ok, got it: if I use this in the serverless.yaml, everythng works like a charm:

- http:
    path: graphql
    method: post
    cors: true
    integration: lambda
    response:
        headers:
            Access-Control-Allow-Origin: "'*'"

cheers a

tobkle commented 7 years ago

Had the same issue. With these corrections it worked. Thanks