Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Modify Plugs.DataToAttributes to follow JSON API sideposting draft

Aberta
#1,303 1 comentário 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
35/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
elixir
Domínio
api, backend

Direção de pesquisa

Comece pelo código DataToAttributes referenciado no issue e revise como JaSerializer.Params.to_attributes lida com relacionamentos belongs-to. Verifique o JSON API sideposting draft e issue #1301 antes de alterar o comportamento. Está concluído quando os relacionamentos de array usam identificadores temp-id para selecionar os registros incluídos correspondentes, enquanto os relacionamentos de map continuam sendo tratados por JaSerializer.Params.to_attributes.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

blocked

Problem

From https://github.com/json-api/json-api/pull/1197/files?short_path=571f6ce#diff-571f6cee9a492e0e177801c21a4b2b2a

Our current approach with included records is to simply assume they are related to the main record.

Based on the draft

  • included record payloads should have temp-id properties if they are to be created.
  • the main record payload should have a relationship where the identifier is %{data: [%{"temp-id" => "foo", "type" => "bar"}
  • the plug should get those identifiers, then replace the identifier payloads with the associated full payloads matched in included

Subtasks

  • instead of just taking any included records and assuming they're relationships in the resulting params map, DataToAttributes should parse the relationships map first
    • the relationship where data is a map is a belongs to and should be left alone. it's already handled by JaSerializer.Params.to_attributes
    • the relationship where data is an array should be checked for identifiers with temp-id keys
      • each temp-id should be found in the included section and added under the pluralized relationship key in the resulting map

An advantage of this is that we now are able to conclude it's definitely a has_many, so we do not need to explicitly specify this anymore.

References

The code this needs to modify is part of #1301 so this is blocked until that is merged.

Linguagem predominante
Elixir
Estrelas
234
Forks
82
Métricas de merge de PRs
Nenhum PR com merge em 30d

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de code-corps/code-corps-api

Todas as issues de code-corps/code-corps-api

Issues semelhantes

Mais issues de Elixir

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.