graphql-jpa-query
graphql-jpa-query copied to clipboard
Mutation
-
Control of access rights for reading entities. The @GraphQLReadEntityForRole annotation indicates which roles are available for reading. If this annotation is not available to everyone. When creating GraphQLJpaSchemaBuilder, you can set predicateRole to which the array of roles is passed and the predicate should return whether the current user has any of the transferred roles.
-
Mutations there are 4 operations insert update merge delete
4 mutations are prepared for each entity insertEntity - insertion of the specified entity, entities specified in the parameters are searched in the database updateEntity - update record by id, entities specified in the parameters are searched in the database mergeEntity - full merge, inserts / updates all specified parameters deleteEntity - delete by id
to process queries in the system graphQL types are created with the prefix specified through suffixInputObjectType (by default, Input)
example queries in MutationTests
- Rights to operations The @GraphQLWriteEntityList and @GraphQLWriteEntityForRole annotation indicates which roles what actions are available. If this annotation is not specified and an access predicate is specified, an exception is raised. When creating GraphQLJpaSchemaBuilderWithMutation, you can set predicateRole to which the array of roles is passed and the predicate should return whether the current user has any of the transferred roles.
This code is still poorly tested.
Codecov Report
Merging #213 into master will increase coverage by
0.2%. The diff coverage is74.54%.
@@ Coverage Diff @@
## master #213 +/- ##
===========================================
+ Coverage 74.05% 74.25% +0.2%
- Complexity 882 1006 +124
===========================================
Files 50 63 +13
Lines 3754 4296 +542
Branches 628 709 +81
===========================================
+ Hits 2780 3190 +410
- Misses 696 778 +82
- Partials 278 328 +50
| Impacted Files | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| ...es/graphql/jpa/query/schema/model/book/Author.java | 0% <ø> (ø) |
0 <0> (ø) |
:arrow_down: |
| ...ures/graphql/jpa/query/schema/model/book/Book.java | 0% <ø> (ø) |
0 <0> (ø) |
:arrow_down: |
| ...phql/jpa/query/schema/ExceptionGraphQLRuntime.java | 0% <0%> (ø) |
0 <0> (?) |
|
| ...s/graphql/jpa/query/schema/impl/FetcherParams.java | 100% <100%> (ø) |
3 <3> (?) |
|
| ...ry/schema/impl/GraphQLJpaOneToManyDataFetcher.java | 74.19% <100%> (+0.42%) |
11 <4> (ø) |
:arrow_down: |
| ...s/graphql/jpa/query/schema/impl/MapEntityType.java | 100% <100%> (ø) |
4 <4> (?) |
|
| ...query/schema/impl/GraphQLJpaSimpleDataFetcher.java | 91.66% <100%> (+0.36%) |
7 <3> (ø) |
:arrow_down: |
| ...a/query/mutations/annotation/GraphQLWriteType.java | 100% <100%> (ø) |
1 <1> (?) |
|
| ...jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java | 91.7% <100%> (+0.08%) |
120 <3> (+2) |
:arrow_up: |
| ...a/query/schema/impl/GraphQLJpaBaseDataFetcher.java | 76.49% <50%> (ø) |
172 <0> (?) |
|
| ... and 25 more |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 0151eec...2322eaf. Read the comment docs.
Is there any update on this? Or is there another way to do mutations?
@miklemv @igdianov
Is this going to get merged at all? I'd love to adopt graphql-jpa-query but I can't without mutation support
I don’t know other ways to apply mutations. I think the use of mutations will be useful, but so far this is a crude solution. If necessary, I will try to support the revision.
Any news? I'd like to use mutations with graphql-jpa-query.
Is there a way to do mutations "normally" using com.coxautodev.graphql.tools.GraphQLMutationResolver ?
Any news? I'd like to use mutations with graphql-jpa-query. Is there a way to do mutations "normally" using
com.coxautodev.graphql.tools.GraphQLMutationResolver?
Yes. You can do any migrations using the standard base class.
@igdianov
will there be an opportunity to do merge? If yes, I can update the branch.
Any news? I'd like to use mutations with graphql-jpa-query. Is there a way to do mutations "normally" using
com.coxautodev.graphql.tools.GraphQLMutationResolver?Yes. You can do any migrations using the standard base class.
I got the following error:
{
"errors": [
{
"message": "Schema is not configured for mutations.",
"locations": [
{
"line": 1,
"column": 1
}
],
"extensions": {
"classification": "OperationNotSupported"
}
}
]
}
I added the file src/main/resources/graphql/subscriber.graphqls with the following content:
type Mutation {
addSubscriber(name: String!, endpoint: String!) : Subscriber
}
The Subscriber type is auto-generated from the schema. Am i missing something? I'm calling the mutation with:
mutation {
addSubscriber(name:"MutationTest", endpoint:"http://test.com") {
name
}
}