Graphcool / graphcool-framework

Apache License 2.0
1.77k stars 131 forks source link

Permission Queries aren't exported correctly #424

Open marktani opened 6 years ago

marktani commented 6 years ago

Issue by Melv Tuesday Nov 28, 2017 at 09:19 GMT Originally opened as https://github.com/graphcool/prisma/issues/1338


Current behavior / Reproduction

graphcool/0.9.2 (linux-x64) node-v6.10.2

Using graphcool init --copy <projectId> to make a copy of a legacy project and make it into a framework service, we notice that permission queries are not exported correctly in several ways.

This is a permission query from our legacy project:

screenshot from 2017-11-28 09-51-31

For this gc init --copy <projectId> generates the file Role.graphql in the permissions folder, the content of this file is:

query read($node_id: ID) {
  SomeRoleExists(filter: {id: $node_id, team: {users_some: {id: $user_id}}})
}

The variable $user_id is not a part of the declaration anymore. This seems to happen with all our permission queries only $node_id stays in the declaration.

Apart from this, if a type has more permission queries the generated file in the permissions folder is also not correct in a different way.

For example our Board type in our legacy project has two permission queries:

screenshot from 2017-11-28 10-00-13

screenshot from 2017-11-28 10-02-38

For this gc init --copy <projectId> generates the file Board.graphql in the permissions folder containing the following code:

query delete($node_id: ID) {
  SomeBoardExists(filter: {AND: [{id: $node_id}, {OR: [{owner: {id: $user_id}}, {team: {owner: {id: $user_id}}}]}]})
}
query  {
  SomeUserExists(filter: {id: $user_id, teams_some: {id: $input_teamId}})
}

The generated graphcool.yml refers to this with the following lines

- operation: Board.delete
  authenticated: true
  query: ./src/permissions/Board.graphql:delete
- operation: Board.create
  authenticated: true
  query: './src/permissions/Board.graphql:'

Notice that the second query (create) has no declaration whatsoever like the delete and because of that the operation: Board.create in graphcool.yml has no reference to create in the query attribute.

Note: Types with more permission queries trigger this message on a deploy

There are issues with the new service definition:

  Global
    ✖ [Ljava.lang.String;@4621534c (of class [Ljava.lang.String;)

Expected behavior?

valid generation of permission queries

marktani commented 6 years ago

Comment by vincenzo Tuesday Nov 28, 2017 at 11:22 GMT


I experienced this, too.