optional/required fields behaviour
@nikgraf ya está trabajando en esto.
Desde el 9/1/2025.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
We should decide how the schema in the framework should behave. In GRC-20 every field except for id, Created at, Updated At, Created by, Versions are optional.
Here our options. For simplicity I would focus on createEntity and useQuery. With this example schema:
{
Todo: {
name: type.Text,
completed: type.Checkbox,
},
}
createEntity({ name: "Setup call", completed: true }); // valid call with all attributes
const result = useQuery({ types: ['Todo']});
/*
[
{ id: "abc", name: "Setup call", completed: true },
{ id: "abc", name: "Draft post", completed: false }
]
*/
Everything always optional
// would be valid and `completed` would just not be set
createEntity({ name: "Setup call" });
const result = useQuery({ types: ['Todo']});
/* returns all entities with the types regardless if they comply to the schema
[
{ id: "abc", name: "Setup call" },
{ id: "abc", completed: false }
]
*/
Everything always required
// valid
createEntity({ name: "Setup call", completed: true });
// would NOT be valid and fail to create the todo
createEntity({ name: "Draft post" });
const result = useQuery({ types: ['Todo']});
/* returns only entities where the entry complies to the schema. Entires like `{ id: "abc", completed: false }` are filtered out
[
{ id: "abc", name: "Setup call", completed: true },
]
*/
Developers can decided
Schema:
{
Todo: {
name: type.Text,
completed: type.Checkbox,
dueUntil: type.Date({ required: false }),
},
}
createEntity({ name: "Setup call", completed: false }); // valid
createEntity({ name: "Draft post", completed: false, dueUntil: "2025-02-10" }); // valid
createEntity({ name: "Do laundry" }); // would NOT be valid and fail to create the todo
const result = useQuery({ types: ['Todo']});
/* returns only entities where the entry complies to the schema. Entires like `{ id: "abc", completed: false }` are filtered out
[
{ id: "abc", name: "Setup call", completed: false },
{ id: "abc", name: "Draft post", completed: false, dueUntil: "2025-02-10" },
]
*/
Other suggestions
Feel free to add your options here …
- Lenguaje dominante
- TypeScript
- Estrellas
- 22
- Forks
- 12
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de graphprotocol/hypergraph
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
graphprotocol/hypergraph#517 ·
-
Section of docs is confusing Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
graphprotocol/hypergraph#323 · 3 comentarios ·
-
Improve Space Inbox Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
graphprotocol/hypergraph#542 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
graphprotocol/hypergraph#529 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
graphprotocol/hypergraph#528 ·
Todos los issues de graphprotocol/hypergraph
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
0xMiden/bridge-portal#132 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
area:tools bug good first issue help wanted priority:P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
TaewoooPark/Motifcode#14 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
newrelic-experimental/preflight#793 · 1 comentario ·