I use GraphQL SPQR with the entity
@Entity
public class MyEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
@GraphQLNonNull
@GraphQLQuery(name = "a", description = "Any field")
private String a;
// Getters and Setters
}
and the service
@Service
@Transactional
public class MyService {
@Autowired
private MyRepository myRepository;
@GraphQLMutation(name = "createEntity")
public MyEntity createEntity(@GraphQLArgument(name = "entity") MyEntity entity) {
myRepository.save(entity);
return entity;
}
}
In GraphiQL I am allowed to set the id
:
mutation {
createEntity(entity: {
id: "11111111-2222-3333-4444-555555555555"
a: "any value"
}) {
id
}
}
But the id
shall not be made editable to the user because it will be overwritten by the DB. It shall only be shown at the queries. I tried and added @GraphQLIgnore
, but the id
is shown all the same.
How can I hide the id
at creation?