sid88in / serverless-appsync-plugin

serverless plugin for appsync
MIT License
951 stars 188 forks source link

Data Source Type not supported: 'HTTP #129

Closed fgiarritiello closed 6 years ago

fgiarritiello commented 6 years ago

I followed the docs to use HTTP data source but I'm getting Data Source Type not supported: 'HTTP error when deploying with serverless. Is this not supported yet?

sid88in commented 6 years ago

is this feature supported in appsync? @nealclark can you please help look into this? reference: https://github.com/sid88in/serverless-appsync-plugin/pull/121

fgiarritiello commented 6 years ago

Yes it is implemented in appsync: https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-http-resolvers.html

sid88in commented 6 years ago

can you try to build this locally in your aws environment? If the mapping templates are configured correctly then it should probably work (I haven't tried running it).

fgiarritiello commented 6 years ago

I think the problem is in the serverless-appsync-plugin version I'm using (1.0.1) which doesn't seem to have the HTTP implementation. What version should I be using for the latest?

sid88in commented 6 years ago

Im planning to do a new release version in like few minutes.

fgiarritiello commented 6 years ago

Thanks, I appreciate it. Also in the next few days I might be able to help with some contribution if it's still needed. Right now I'm too busy at work.

nealclark commented 6 years ago

The feature is supported in appsync and I have used it to create and map an http endpoint.

  dataSources:
    - type: HTTP
      name: ChuckNorrisAPI
      description: Connection to Chuck Norris Api
      config:
        endpoint: https://api.icndb.com
  mappingTemplates:
    - dataSource: ChuckNorrisAPI
      type: Query
      field: getJoke
      request: getJoke-request.vm
      response: getJoke-response.vm
// getJoke-request.vm
{
    "version": "2018-05-29",
    "method": "GET",
    "resourcePath": "/jokes/random"
}

// getJoke-response.vm
## if the response status code is not 200, then return an error. Else return the body **
#if($ctx.result.statusCode == 200)
    ## If response is 200, return the body.
    $util.toJson($util.parseJson($context.result.body).value)
#else
    ## If response is not 200, append the response to error block.
    $utils.appendError($ctx.result.body, $ctx.result.statusCode)
#end
type Query {
  getJoke: Joke
}

type Joke {
  id: Int
  joke: String
}
sid88in commented 6 years ago

^ just published version 1.0.2. Can you please test again and include instructions / example in readme

fgiarritiello commented 6 years ago

You guys are awesome!!!

fgiarritiello commented 6 years ago

Sorry, I updated to 1.0.2 but I'm getting the following error now when deploying with serverless:

ENOENT: no such file or directory, open '/Users/fernando/github/cloud/services/serverless-appsync-plugin/example/schema.graphql' at Object.fs.openSync (fs.js:646:18) at Object.fs.readFileSync (fs.js:551:33) at module.exports (/Users/fernando/github/cloud/services/appsync/node_modules/serverless-appsync-plugin/get-config.js:48:28) at ServerlessAppsyncPlugin.loadConfig (/Users/fernando/github/cloud/services/appsync/node_modules/serverless-appsync-plugin/index.js:42:12) at ServerlessAppsyncPlugin.getSchema (/Users/fernando/github/cloud/services/appsync/node_modules/serverless-appsync-plugin/index.js:50:29) at ServerlessAppsyncPlugin.validateSchema (/Users/fernando/github/cloud/services/appsync/node_modules/serverless-appsync-plugin/index.js:68:25) at Object.before:deploy:initialize [as hook] (/Users/fernando/github/cloud/services/appsync/node_modules/serverless-appsync-plugin/index.js:33:46)

hypexr commented 6 years ago

I'm also getting this error after upgrading to 1.0.2. HTTP data sources we're working for me when sourcing github prior to this.

sid88in commented 6 years ago

@fgiarritiello there was a bug with v1.0.2. I have just published v1.0.3 Please try again

hypexr commented 6 years ago

@sid88in That fixed the "no such file or directory" problem for me.

sid88in commented 6 years ago

thanks to @Znergy ;)

victorbasumatary commented 3 years ago

This was the only relevant result I got when looking up this issue on Google so I'll just leave here how I resolved my issue:

Check the dataSources section. An incorrect configuration can also cause this issue.