Skip to content

Mutation#213

Open
miklemv wants to merge 10 commits into
introproventures:masterfrom
miklemv:mutation
Open

Mutation#213
miklemv wants to merge 10 commits into
introproventures:masterfrom
miklemv:mutation

Conversation

@miklemv
Copy link
Copy Markdown
Contributor

@miklemv miklemv commented Nov 9, 2019

  1. 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.

  2. 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

  1. 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
Copy link
Copy Markdown

codecov Bot commented Nov 9, 2019

Codecov Report

❌ Patch coverage is 74.54545% with 140 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.25%. Comparing base (0151eec) to head (2322eaf).
⚠️ Report is 410 commits behind head on master.

Files with missing lines Patch % Lines
...ons/fetcher/impl/GraphQLJpaEntityInputFetcher.java 68.60% 43 Missing and 27 partials ⚠️
...mutations/GraphQLJpaSchemaBuilderWithMutation.java 78.35% 16 Missing and 5 partials ⚠️
...jpa/query/mutations/fetcher/impl/MergeFetcher.java 80.23% 10 Missing and 7 partials ⚠️
...l/jpa/query/schema/impl/GraphQLJpaBaseFetcher.java 72.50% 5 Missing and 6 partials ⚠️
...phql/jpa/query/schema/ExceptionGraphQLRuntime.java 0.00% 6 Missing ⚠️
...pa/query/mutations/fetcher/impl/DeleteFetcher.java 63.63% 4 Missing ⚠️
...pa/query/mutations/fetcher/impl/UpdateFetcher.java 71.42% 4 Missing ⚠️
...mutations/fetcher/impl/GraphQLStdDeserializer.java 87.50% 2 Missing ⚠️
...jpa/query/mutations/fetcher/impl/InsertFecher.java 83.33% 2 Missing ⚠️
...l/jpa/query/mutations/fetcher/MutationContext.java 87.50% 1 Missing ⚠️
... and 2 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #213      +/-   ##
============================================
+ Coverage     74.05%   74.25%   +0.20%     
- 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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@markxj
Copy link
Copy Markdown

markxj commented Mar 18, 2020

Is there any update on this? Or is there another way to do mutations?

@markxj
Copy link
Copy Markdown

markxj commented Apr 6, 2020

@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

@miklemv
Copy link
Copy Markdown
Contributor Author

miklemv commented Apr 13, 2020

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.

@federico-s
Copy link
Copy Markdown

federico-s commented Apr 22, 2020

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 ?

@miklemv
Copy link
Copy Markdown
Contributor Author

miklemv commented Apr 22, 2020

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.

@miklemv
Copy link
Copy Markdown
Contributor Author

miklemv commented Apr 22, 2020

@igdianov

will there be an opportunity to do merge? If yes, I can update the branch.

@federico-s
Copy link
Copy Markdown

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
  }
}

@igdianov igdianov force-pushed the master branch 3 times, most recently from 62d001d to e72c364 Compare October 14, 2025 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants