I'm trying to use inline fragment, is it not supp...
# orm-help
z
I'm trying to use inline fragment, is it not supported in Prisma?
Copy code
mutation($scaffoldId: ID!, $key: String!, $value: String!, $includeFragment: Boolean!) {
    updateScaffold(scaffoldId: $scaffoldId, key: $key, value: $value) {
      id
      title
      ... @include(if: $includeFragment) {
        department {
          id
          title
          organisation {
            title
          }
        }
      }
    }
  }
n
I don't recognize this as valid syntax. What is the response you receive for this mutation?
z
"Cannot read property 'name' of undefined"
n
How are you sending this query?
z
Apollo client ?
n
This is a javascript error, so unrelated to the Prisma API.
Can you reproduce an error by sending this query to the Prisma API directly?
z
Prisma gives me this error - server side
Copy code
TypeError: Cannot read property 'name' of undefined
    at /home/david/Atom/hamar-api/node_modules/graphql-binding/node_modules/graphql-tools/dist/transforms/ExpandAbstractTypes.js:110:73
    at Array.forEach (<anonymous>)
    at Object.graphql_1.visit.graphql_1.visitWithTypeInfo._a.(anonymous function) [as SelectionSet] (/home/david/Atom/hamar-api/node_modules/graphql-binding/node_modules/graphql-tools/dist/transforms/ExpandAbstractTypes.js:108:29)
    at Object.enter (/home/david/Atom/hamar-api/node_modules/graphql/language/visitor.js:366:25)
    at Object.visit (/home/david/Atom/hamar-api/node_modules/graphql/language/visitor.js:254:26)
    at expandAbstractTypes (/home/david/Atom/hamar-api/node_modules/graphql-binding/node_modules/graphql-tools/dist/transforms/ExpandAbstractTypes.js:104:22)
    at ExpandAbstractTypes.transformRequest (/home/david/Atom/hamar-api/node_modules/graphql-binding/node_modules/graphql-tools/dist/transforms/ExpandAbstractTypes.js:20:24)
    at /home/david/Atom/hamar-api/node_modules/graphql-binding/node_modules/graphql-tools/dist/transforms/transforms.js:12:25
    at Array.reduce (<anonymous>)
    at Object.applyRequestTransforms (/home/david/Atom/hamar-api/node_modules/graphql-binding/node_modules/graphql-tools/dist/transforms/transforms.js:10:23)
n
This is not an error returned by the Prisma API, as it is a JavaScript error.
z
ok, are inline fragments supported on Prisma?
n
To the best of my knowledge, they are. What you shared in your first post is, to the best of my knowledge, not valid GraphQL syntax.
z
the @include part?
n
Yes. The entire document is not a valid mutation.
Also, I recommend you to cut out the entire JavaScript part and use Playground/`cURL` until you figured out the right syntax 🙂
z
hmm don't know what you mean by that, the mutation worked perfectly until I added the @include directive 😕
n
This is the mutation without the
@include
directive:
Copy code
mutation($scaffoldId: ID!, $key: String!, $value: String!, $includeFragment: Boolean!) {
  updateScaffold(scaffoldId: $scaffoldId, key: $key, value: $value) {
    id
    title
    {
      department {
        id
        title
        organisation {
          title
        }
      }
    }
  }
}
This is not valid GraphQL syntax.
z
no, the department {...} is the fragment and the brackets surrounding the fragment are required as by https://graphql.org/learn/queries/#directives
n
The
department { ... }
is not a fragment.
it's a selection set.
z
hmm you're right about that... thx, I think you've just found the error...
but surely I can use directives on selection sets?
Ahh... beautiful, it's working = thank you Nilan you saved my day - and I learned some!
n
you're most welcome 🙂