DEV Community

Creating a JSON API with Athena & Granite

Blacksmoke16 on February 27, 2019

UPDATE: April 22, 2019 for Athena version 0.6.0 UPDATE: November 24, 2019 for Athena version 0.7.0 and Crystal 0.31.1 UPDATE: February 7, 2020 for ...
Collapse
 
phangs profile image
phangs • • Edited

I tried following this tutorial to learn about crystal and api. I am newbie programmer btw.

Following the steps manually and cloning the github source yield the same error:

In src/blog.cr:2:1

2 | Granite::Adapters << Granite::Adapter::Pg.new({name: "my_blog", url: "postgres://dbadmin:password@localhost:5432/blog?currentSchema=blog"})
----------------
Error: undefined constant Granite::Adapters

Did you mean 'Granite::Adapter'?

can you please help what I am doing wrong?

Collapse
 
blacksmoke16 profile image
Blacksmoke16 •

This is a result of some breaking changes that happened in the new Granite version. See github.com/amberframework/granite/...

I'll update the guide to reflect those changes.

Collapse
 
phangs profile image
phangs •

Thank you! Looking forward to the update

Thread Thread
 
blacksmoke16 profile image
Blacksmoke16 •

Should be good to go now, let me know if you run into any trouble.

Thread Thread
 
phangs profile image
phangs •

tried the source again from the repo, new error:

Athena::Routing::Converters::Athena::Routing::Converters::RequestBody(Blog::Models::Article, Nil).new.convert val
--------------------------------------------------------------------
Error: undefined constant Athena::Routing::Converters::Athena::Routing::Converters::RequestBody

I'm still figuring out the problem just would like to let you know.

Thread Thread
 
blacksmoke16 profile image
Blacksmoke16 • • Edited

Make sure you do a shards update I updated some dependencies and pinned the versions so it'll always use the correct version.