question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: definitions.trim is not a function

See original GitHub issue

Bug report

when running against the latest release (5.3.5) against the latest release of graphql(1.17.4) yoga. I receive the following error.

If I rollback yoga to (1.17.1) the error disappears. Seems to be caused by yoga upgrading their version of graphql-middleware from 3.0.1 to 3.0.2.

TypeError: definitions.trim is not a function
    at parseFragmentToInlineFragment (/Users/rorykelly/Desktop/Rockspin/CuratedServer/node_modules/graphql-middleware/src/fragments.ts:85:21)
    at /Users/rorykelly/Desktop/Rockspin/CuratedServer/node_modules/graphql-middleware/src/fragments.ts:41:24
    at Array.map (<anonymous>)
    at Object.extractFragmentReplacements (/Users/rorykelly/Desktop/Rockspin/CuratedServer/node_modules/graphql-middleware/src/fragments.ts:40:6)
    at addMiddlewareToSchema (/Users/rorykelly/Desktop/Rockspin/CuratedServer/node_modules/graphql-middleware/src/middleware.ts:40:32)
    at normalisedMiddlewares.reduceRight.schema (/Users/rorykelly/Desktop/Rockspin/CuratedServer/node_modules/graphql-middleware/src/middleware.ts:86:13)
    at Array.reduceRight (<anonymous>)
    at applyMiddlewareWithOptions (/Users/rorykelly/Desktop/Rockspin/CuratedServer/node_modules/graphql-middleware/src/middleware.ts:78:77)
    at applyMiddleware (/Users/rorykelly/Desktop/Rockspin/CuratedServer/node_modules/graphql-middleware/src/middleware.ts:129:36)
    at new GraphQLServer (/Users/rorykelly/Desktop/Rockspin/CuratedServer/node_modules/graphql-yoga/src/index.ts:137:13)

To Reproduce

Expected behavior

Yoga Server should start.

Actual behaviour

Receive above error.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:11

github_iconTop GitHub Comments

2reactions
gihrigcommented, Jul 21, 2019

As suggested by @RoryKelly the issue is caused by graphql-middleware update to 3.0.2, a dependency of graphql-yoga 1.17.2+

It can be corrected by requiring graphql-middleware 3.0.1 as follows. Only works with yarn, npm install does not process resolutions

package.json

"resolutions": {
  "graphql-middleware": "3.0.1"
}

See graphql-middleware #198

graphql-yoga latest (1.18.1) appears to work as expected with graphql-midleware 3.0.1

1reaction
bizmediacommented, Jul 19, 2019

Could someone compose a simple reproduction repository? This way, I can identify the issue more quickly.

https://github.com/prisma/photonjs/tree/master/examples/typescript/graphql-auth

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - .trim() is not a function - Stack Overflow
you should be getting TypeError: array. · The split() method splits a String object into an array of strings by separating the string...
Read more >
[Solved] TypeError: trim is not a function - ItsJavaScript
The TypeError: trim is not a function occurs if we call a trim() method on the value that is not of a type...
Read more >
TypeError: definitions.trim is not a function · Issue #361 - GitHub
Bug report when running against the latest release (5.3.5) against the latest release of graphql(1.17.4) yoga. I receive the following error ...
Read more >
definitions.trim is not a function when using gql tag with ...
From where you're importing gql could you please share this information? You can either use: import { gql } from 'apollo-boost' // OR...
Read more >
d.trim() is not a function - datetime-moment.js - DataTables
Link to test case: N/A Debugger code (debug.datatables.net): N/A Error messages shown: Uncaught TypeError: d.trim is not a function at Array ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found