You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(graphql): Allow including 'File' scalar by default to be disabled (#11540)
There was a problem introduced in v8 when we included the `File` scalar
by default. This meant a custom implementation by the user could be
clobbered by the new default. This change allows the user to supply
config to disable including it by default.
This is not how I would have loved to have done things here. Config in
two places is rubbish but given the organisation of this currently it
was generally unavoidable.
- fix(graphql): Allow including 'File' scalar by default to be disabled (#11540) by @Josh-Walker-GM
2
+
3
+
As of v8.0.0 a `File` scalar was added to your graphql schema by default. This could be problematic if you wanted to define your own `File` scalar.
4
+
5
+
With this change it is now possible to disable including this scalar by default. To see how to do so look at the `Default Scalar` section of the `Graphql` docs [here](https://docs.redwoodjs.com/docs/graphql#default-scalars)
Copy file name to clipboardExpand all lines: docs/docs/graphql.md
+37Lines changed: 37 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -689,6 +689,43 @@ api | - deletePost Mutation
689
689
690
690
To fix these errors, simple declare with `@requireAuth` to enforce authentication or `@skipAuth` to keep the operation public on each as appropriate for your app's permissions needs.
691
691
692
+
## Default Scalars
693
+
694
+
Redwood includes a selection of scalar types by default.
695
+
696
+
Currently we allow you to control whether or not the `File` scalar is included automatically or not. By default we include the `File` scalar which maps to the standard `File` type. To disable this scalar you should add config to two places:
697
+
698
+
1. In your `redwood.toml` file like so:
699
+
700
+
```toml
701
+
[graphql]
702
+
includeScalars.File=false
703
+
```
704
+
705
+
2. In your `functions/graphql.ts` like so:
706
+
707
+
```typescript
708
+
exportconsthandler=createGraphQLHandler({
709
+
authDecoder,
710
+
getCurrentUser,
711
+
loggerConfig: { logger, options: {} },
712
+
directives,
713
+
sdls,
714
+
services,
715
+
onException: () => {
716
+
// Disconnect from your database with an unhandled exception.
717
+
db.$disconnect()
718
+
},
719
+
// highlight-start
720
+
includeScalars: {
721
+
File:false,
722
+
},
723
+
// highlight-end
724
+
})
725
+
```
726
+
727
+
With those two config values added your schema will no longer contain the `File` scalar by default and you are free to add your own or continue without one.
728
+
692
729
## Custom Scalars
693
730
694
731
GraphQL scalar types give data meaning and validate that their values makes sense. Out of the box, GraphQL comes with `Int`, `Float`, `String`, `Boolean` and `ID`. While those can cover a wide variety of use cases, you may need more specific scalar types to better describe and validate your application's data.
0 commit comments