Closed fgiarritiello closed 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
Yes it is implemented in appsync: https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-http-resolvers.html
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).
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?
Im planning to do a new release version in like few minutes.
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.
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
}
^ just published version 1.0.2. Can you please test again and include instructions / example in readme
You guys are awesome!!!
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)
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.
@fgiarritiello there was a bug with v1.0.2. I have just published v1.0.3 Please try again
@sid88in That fixed the "no such file or directory" problem for me.
thanks to @Znergy ;)
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.
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?