Emily

Emily

Mixed Naming Conventions, Best Practices?... Mixing Elixir With Js, Vuejs

I’m using VueJS for the front-end of this project. File conventions are CamelCase, Elixir, snake_case.

Variable conventions differ too.

I’ve been following conventions, depending on language, but now code looks Frankenstein as a result, with inconsistent filenames & variable naming.

I can see this becoming a big problem when sharing variables between languages. How is the problem generally handled? What are the best practices here?

Do I mix & match conventions according to language? Or keep 1 universal convention for all modules in the project, regardless of language?

And if its the former, how is this problem handled when sharing variables between 2 languages?

Most Liked

manukall

manukall

i’m following conventions in both parts. i use camel case variables in javascript and snake case in elixir.

to share data between elixir and javascript, you are going to use some form of api. this is the point where many transform then between camel case and snake case. if you’re going for absinthe/graphql for example, you will write your schema in elixir with camel case (field :first_name) and your queries from javascript can use camel case (firstName) and it gets automatically matched.

pierreabreup

pierreabreup

@Emily @manukall Absinthe has an adapter to convert snake_case to camelCase ( absinthe/guides/adapters.md at main · absinthe-graphql/absinthe · GitHub ). I’m using this adapter and it works very well

.

The schema has to be snake_case to adapter works.

My project is a phoenix (version 1.4.) framework using absinthe (version 1.4.13) and absinthe_plug (version 1.4.6). To set up an absithe adapter, go to config.exs file and add the line below

config :absinthe, adapter: Absinthe.Adapter.LanguageConventions

Where Next?

Popular in Questions Top

New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> somethi...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
Kurisu
For example for a current url like http://localhost:4000/cosmetic/products?_utf8=✓&query=perfume&page=2, I would like to get: ...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement